Add import multi support

This commit is contained in:
2026-01-19 15:10:34 +08:00
parent c075d4593f
commit 4670f4e2e7
6 changed files with 450 additions and 4 deletions

View File

@@ -5,6 +5,11 @@ pub trait VecExt<T> {
fn copy_overlapped(&mut self, src: usize, dst: usize, len: usize);
}
pub trait VecExt2<T> {
/// Pop the first element of the vector, returning `None` if empty.
fn pop_first(&mut self) -> Option<T>;
}
impl<T: Copy> VecExt<T> for Vec<T> {
fn copy_overlapped(&mut self, src: usize, dst: usize, mut len: usize) {
let mut src = src.min(self.len());
@@ -26,3 +31,13 @@ impl<T: Copy> VecExt<T> for Vec<T> {
}
}
}
impl<T> VecExt2<T> for Vec<T> {
fn pop_first(&mut self) -> Option<T> {
if self.is_empty() {
None
} else {
Some(self.remove(0))
}
}
}