summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorMarek Barvíř <barvirm@gmail.com>2023-03-31 17:13:31 +0200
committerGitHub <noreply@github.com>2023-03-31 17:13:31 +0200
commit4161bad54f690e77f53ca1f0f4426161e60fa4ce (patch)
tree4cde0d6d8d2b536871230f84dcf0fbec798f4056 /src/eval
parent418bd89ba4c5f50c7e279a84d7a0e3c51d319449 (diff)
FIX lint clippy::len_without_is_empty (#451)
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/array.rs5
-rw-r--r--src/eval/str.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/eval/array.rs b/src/eval/array.rs
index 3006c91f..8dcbd5a9 100644
--- a/src/eval/array.rs
+++ b/src/eval/array.rs
@@ -41,6 +41,11 @@ impl Array {
Self(vec)
}
+ /// Return `true` if the length is 0.
+ pub fn is_empty(&self) -> bool {
+ self.0.len() == 0
+ }
+
/// The length of the array.
pub fn len(&self) -> i64 {
self.0.len() as i64
diff --git a/src/eval/str.rs b/src/eval/str.rs
index d867e19c..22b5498b 100644
--- a/src/eval/str.rs
+++ b/src/eval/str.rs
@@ -34,6 +34,11 @@ impl Str {
Self(EcoString::new())
}
+ /// Return `true` if the length is 0.
+ pub fn is_empty(&self) -> bool {
+ self.0.len() == 0
+ }
+
/// The length of the string in bytes.
pub fn len(&self) -> i64 {
self.0.len() as i64