Fix Array::chop.
This commit is contained in:
@@ -171,11 +171,11 @@ pub mod array_functions {
|
||||
}
|
||||
}
|
||||
pub fn chop(array: &mut Array, len: INT) {
|
||||
if !array.is_empty() && len as usize >= array.len() {
|
||||
if len >= 0 {
|
||||
array.drain(0..array.len() - len as usize);
|
||||
} else {
|
||||
if !array.is_empty() {
|
||||
if len <= 0 {
|
||||
array.clear();
|
||||
} else if (len as usize) < array.len() {
|
||||
array.drain(0..array.len() - len as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -162,11 +162,11 @@ pub mod blob_functions {
|
||||
}
|
||||
}
|
||||
pub fn chop(blob: &mut Blob, len: INT) {
|
||||
if !blob.is_empty() && len as usize >= blob.len() {
|
||||
if len >= 0 {
|
||||
blob.drain(0..blob.len() - len as usize);
|
||||
} else {
|
||||
if !blob.is_empty() {
|
||||
if len <= 0 {
|
||||
blob.clear();
|
||||
} else if (len as usize) < blob.len() {
|
||||
blob.drain(0..blob.len() - len as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user