Skip to content

Commit 4fe8a3d

Browse files
committed
Merge pull request #39 from yanns/remove_mut_ref
AtomicUsize does not need a mutable reference to be increment
2 parents feaf6af + b12c2c6 commit 4fe8a3d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/threaded_with_shared_counter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ struct Context {
2121
}
2222

2323
trait Counter {
24-
fn increment(&mut self);
24+
fn increment(&self);
2525
fn get(&self) -> usize;
2626
}
2727

2828
impl Counter for Context {
29-
fn increment(&mut self) { self.counter.fetch_add(1, Ordering::SeqCst); }
29+
fn increment(&self) { self.counter.fetch_add(1, Ordering::SeqCst); }
3030
fn get(&self) -> usize { self.counter.load(Ordering::SeqCst) }
3131
}
3232

0 commit comments

Comments
 (0)