struct Foo {}
let mut vec: Vec<Foo> = Vec::new();
println!("{}", vec.capacity());
output: 18446744073709551615
Hi @yakoshk, is there any reason this should be an issue? The struct Foo in this case has size zero, and it is expected that the Vec behaves like this with such elements. It uses no allocation and can store as many elements as fits in its capacity counter.
To be clear, though, vec.len() should be 0 for an empty Vec, regardless of the type.
@mark-i-m Was that perhaps a mistype? There's no mention of vec.len() here.
@bstrie Yes, but I thought maybe there might have been confusion between capacity and len.
Most helpful comment
Hi @yakoshk, is there any reason this should be an issue? The
struct Fooin this case has size zero, and it is expected that the Vec behaves like this with such elements. It uses no allocation and can store as many elements as fits in its capacity counter.