nomicon
nomicon copied to clipboard
trivial: if Vec::into_iter() mispelled the comments ?
https://github.com/rust-lang/nomicon/blob/master/src/vec/vec-into-iter.md#L62
impl<T> Vec<T> {
pub fn into_iter(self) -> IntoIter<T> {
// Can't destructure Vec since it's Drop <=== if 'Drop' should be 'Copy' ?
let ptr = self.ptr;
let cap = self.cap;
let len = self.len;
Can you say more about what you think is wrong? I think the comment is saying you can't destructure with something like let Vec{ptr, cap, len} = self; because that would drop it, which it explicitly does not want to do.
Thanks for your quick reply!
My poor english & less rust experience misled me :-/ I thought the comment was for let ptr=self.ptr, that self.ptr's type is NonNull which implemented Copy trait, so the statement could not destroy the buffer. My bad, sorry.
By the way, how let Vec{ptr, cap, len} = self would drop it? I tried that self still accessible after this.
Oh, good point! I don't know what the comment means then. 🙃