mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-07 13:28:47 +08:00
Add import multi support
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user