commitlog
commitlog copied to clipboard
truncate cannot remove first element
Truncate deletes all entries after offset. This makes it impossible to remove the first element, because it is retained even when truncate(0)
. I believe it is for this reason that truncate on Vec<T> also truncates the element passed.
fn main() {
let mut vec = vec![1,2,3];
vec.truncate(0);
println!("{:?}", vec);
}
>>> []
I'd be happy to open a PR on this if I knew what direction you wanted to take it. New method or update the old one?
@davlum Good find! Can we add another method, and possibly truncate
to the new method adjusting for the exclusion logic?