mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 05:24:51 +00:00
fix: use split_off to take n
This commit is contained in:
parent
3a0b8d9d58
commit
6fd81c8d20
1 changed files with 6 additions and 2 deletions
|
@ -440,7 +440,9 @@ impl<T: Clone + PartialEq + Debug> DeltaValue for Vec<T> {
|
|||
}
|
||||
|
||||
fn take(&mut self, length: usize) -> Self {
|
||||
self.drain(0..length).collect()
|
||||
let mut new = self.split_off(length);
|
||||
std::mem::swap(self, &mut new);
|
||||
new
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +452,9 @@ impl DeltaValue for String {
|
|||
}
|
||||
|
||||
fn take(&mut self, length: usize) -> Self {
|
||||
self.drain(0..length).collect()
|
||||
let mut new = self.split_off(length);
|
||||
std::mem::swap(self, &mut new);
|
||||
new
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue