You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-09-16 17:46:35 +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:
@@ -7,11 +7,10 @@ behind a read-only interface:
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
fn main() {
|
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());
|
println!("v: {:?}", v.lock().unwrap());
|
||||||
|
|
||||||
{
|
{
|
||||||
let v: &Mutex<Vec<i32>> = &v;
|
|
||||||
let mut guard = v.lock().unwrap();
|
let mut guard = v.lock().unwrap();
|
||||||
guard.push(40);
|
guard.push(40);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user