A small feature request, maybe something like
Vec::new_reserved(size: usize) could be useful? Sometimes when extracting data in code I keep writing long structures like:
let mut v = vec!;
// Can be replaced with
They are not very readable and might be useful for others too. It might come in handy for iterators too, since now ones that have a
size_hint can request the required amount of space when collecting:
Right, sorry lol, could not find this in the docs. Well, at least it will be helpful to whomever finds this post next.
EDIT: Maybe this should a clippy warning then?
Sounds like a reasonable idea to me. I tried searching for pre-existing proposals in the relevant issue tracker and didn’t see anything so far. Feel free to open a new one ^^
Great minds think alike?
I guess that one is specifically for zero-initialized data, but it's probably related.
Looks like maybe this is about using
BTW, libstd is lacking
Vec::new(); vec.try_reserve()? is the only non-aborting option.