As far as I see, the best way to move the first (or the last) element out of a Vec1 with the current implementation is something like v.into_vec().remove(0). It would be more convenient to have methods to extract the first and the last element, e. g.:
impl<T> Vec1<T> {
pub fn split_off_first(self) -> (T, Vec<T>) {
let mut vec = self.0;
let first = vec.remove(0);
(first, vec)
}
pub fn split_off_last(self) -> (Vec<T>, T) {
let mut vec = self.0;
let last = vec.remove(vec.len() - 1);
(vec, last)
}
}
Did I miss something? Would you accept a PR adding these two methods?
As far as I see, the best way to move the first (or the last) element out of a
Vec1
with the current implementation is something likev.into_vec().remove(0)
. It would be more convenient to have methods to extract the first and the last element, e. g.:Did I miss something? Would you accept a PR adding these two methods?