mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-02 11:03:18 +02:00
Remove explicit typing in Mutex example (#405)
Example contained unnecessary explicit type info for the vector in Mutex v. Rust will magically do the needful conversions for us. Code looks cleaner/simpler without the explicit typing.
This commit is contained in:
parent
8ff5a54599
commit
916c297d8c
@ -7,11 +7,10 @@ behind a read-only interface:
|
||||
use std::sync::Mutex;
|
||||
|
||||
fn main() {
|
||||
let v: Mutex<Vec<i32>> = Mutex::new(vec![10, 20, 30]);
|
||||
let v = Mutex::new(vec![10, 20, 30]);
|
||||
println!("v: {:?}", v.lock().unwrap());
|
||||
|
||||
{
|
||||
let v: &Mutex<Vec<i32>> = &v;
|
||||
let mut guard = v.lock().unwrap();
|
||||
guard.push(40);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user