std::vec: Use a valid value as lifetime dummy in iterator
The current implementation uses `&v[0]` for the lifetime struct field, but that is a dangling pointer for iterators derived from zero-length slices. Example: let v: [int, ..0] = []; println!("{:?}", v.iter()) std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128} To replace this parameter, use a field of type `Option<&'self ()>` that is simply initialized with `None`, but still allows the iterator to have a lifetime parameter.
Showing
想要评论请 注册 或 登录