Skip to content

Commit 28aca4a

Browse files
authored
Merge pull request #1463 from andri-reveli/master
fix formatting
2 parents 40bb392 + a892713 commit 28aca4a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/std/arc.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@
33
When shared ownership between threads is needed, `Arc`(Atomic Reference Counted) can be used. This struct, via the `Clone` implementation can create a reference pointer for the location of a value in the memory heap while increasing the reference counter. As it shares ownership between threads, when the last reference pointer to a value is out of scope, the variable is dropped.
44

55
```rust,editable
6-
7-
fn main() {
86
use std::sync::Arc;
97
use std::thread;
108
11-
// This variable declaration is where its value is specified.
12-
let apple = Arc::new("the same apple");
9+
fn main() {
10+
// This variable declaration is where its value is specified.
11+
let apple = Arc::new("the same apple");
1312
14-
for _ in 0..10 {
15-
// Here there is no value specification as it is a pointer to a reference
16-
// in the memory heap.
17-
let apple = Arc::clone(&apple);
13+
for _ in 0..10 {
14+
// Here there is no value specification as it is a pointer to a reference
15+
// in the memory heap.
16+
let apple = Arc::clone(&apple);
1817
19-
thread::spawn(move || {
20-
// As Arc was used, threads can be spawned using the value allocated
21-
// in the Arc variable pointer's location.
22-
println!("{:?}", apple);
23-
});
24-
}
18+
thread::spawn(move || {
19+
// As Arc was used, threads can be spawned using the value allocated
20+
// in the Arc variable pointer's location.
21+
println!("{:?}", apple);
22+
});
23+
}
2524
}
2625
2726
```

0 commit comments

Comments
 (0)