Hacker News new | ask | show | jobs
by tialaramex 262 days ago
It is of course impossible to know the context in which you saw this, but I will say this is a particular idiomatic way to write Rust which won't mesh with your C knowledge.

Also this code isn't a thing you'd actually do, it's maybe an illustration or part of an example I suppose

You see that vec![1, 2, 3] ? That's what we're getting at the end, a growable array with three integers in it. All the other stuff is machinery to handle errors which in fact have not happened.

    let flattened = vec![1, 2, 3];
Is the same effect, although probably for style you'd write:

    let flattened: Vec<i32> = vec![1, 2, 3];