From 3cb3dc8e4f247c57bf49c5aaf774d4d715e3ed4f Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 24 Apr 2020 20:05:34 +0800 Subject: [PATCH] Fix shift function. --- src/packages/array_basic.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/array_basic.rs b/src/packages/array_basic.rs index e50224ac..b00f012c 100644 --- a/src/packages/array_basic.rs +++ b/src/packages/array_basic.rs @@ -78,7 +78,7 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, { lib, "shift", |list: &mut Array| { - if !list.is_empty() { + if list.is_empty() { ().into() } else { list.remove(0) @@ -106,6 +106,8 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, { |list: &mut Array, len: INT| { if len >= 0 { list.truncate(len as usize); + } else { + list.clear(); } }, map,