From dad0d7f0eb298768bfc838e00a6b04302e2c70e0 Mon Sep 17 00:00:00 2001 From: lihuan Date: Wed, 27 Sep 2023 18:46:36 +0800 Subject: [PATCH] Update ch19-01-unsafe-rust.md --- src/ch19-01-unsafe-rust.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ch19-01-unsafe-rust.md b/src/ch19-01-unsafe-rust.md index 6ff229dd37..b303be7116 100644 --- a/src/ch19-01-unsafe-rust.md +++ b/src/ch19-01-unsafe-rust.md @@ -389,14 +389,14 @@ static variable named `COUNTER`. {{#rustdoc_include ../listings/ch19-advanced-features/listing-19-10/src/main.rs}} ``` -Listing 19-10: Reading from or writing to a mutable -static variable is unsafe +Listing 19-10: Accessing or modifying a mutable static +variable is unsafe As with regular variables, we specify mutability using the `mut` keyword. Any -code that reads or writes from `COUNTER` must be within an `unsafe` block. This -code compiles and prints `COUNTER: 3` as we would expect because it’s single -threaded. Having multiple threads access `COUNTER` would likely result in data -races. +code that accessing or modifying `COUNTER` must be within an `unsafe` block. +This code compiles and prints `COUNTER: 3` as we would expect because it’s +single threaded. Having multiple threads access `COUNTER` would likely result +in data races. With mutable data that is globally accessible, it’s difficult to ensure there are no data races, which is why Rust considers mutable static variables to be