3 ms·
Rust's type checker is very clever tough. You can omit types almost anywhere, and rust will infer it. Say you net a vector containing Foo object. You can just d
by posix86 4y ago
Rust's type checker is very clever tough. You can omit types almost anywhere, and rust will infer it. Say you net a vector containing Foo object. You can just do
let mut v = Vec::new();
v.push(m_foo);
In fact it's so nice that you often rewrite code to keep clear what's actually happening, even though you could keep types largely implicit.
Here's another example:
let f: Vec<i32> = vec![1, 2];
let f2: HashSet<f32> = f.iter().map(|n|n.into()).collect();