Fix Array::chop.
This commit is contained in:
parent
96764c0d2d
commit
e2e0b8d083
@ -8,6 +8,7 @@ Bug fixes
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* Padding arrays with another array via `pad` no longer loops indefinitely.
|
* Padding arrays with another array via `pad` no longer loops indefinitely.
|
||||||
|
* `chop` for arrays and BLOB's now works properly.
|
||||||
* `set_bit` for bit-flags with negative index now works correctly.
|
* `set_bit` for bit-flags with negative index now works correctly.
|
||||||
* Misnamed `params` field `name` in the JSON output of `Engine::gen_fn_metadata_to_json` is fixed (was incorrectly named `type`).
|
* Misnamed `params` field `name` in the JSON output of `Engine::gen_fn_metadata_to_json` is fixed (was incorrectly named `type`).
|
||||||
|
|
||||||
|
@ -171,11 +171,11 @@ pub mod array_functions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn chop(array: &mut Array, len: INT) {
|
pub fn chop(array: &mut Array, len: INT) {
|
||||||
if !array.is_empty() && len as usize >= array.len() {
|
if !array.is_empty() {
|
||||||
if len >= 0 {
|
if len <= 0 {
|
||||||
array.drain(0..array.len() - len as usize);
|
|
||||||
} else {
|
|
||||||
array.clear();
|
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) {
|
pub fn chop(blob: &mut Blob, len: INT) {
|
||||||
if !blob.is_empty() && len as usize >= blob.len() {
|
if !blob.is_empty() {
|
||||||
if len >= 0 {
|
if len <= 0 {
|
||||||
blob.drain(0..blob.len() - len as usize);
|
|
||||||
} else {
|
|
||||||
blob.clear();
|
blob.clear();
|
||||||
|
} else if (len as usize) < blob.len() {
|
||||||
|
blob.drain(0..blob.len() - len as usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user