pub trait Length: Collection {
// Required method
fn len(&self) -> usize;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn is_not_empty(&self) -> bool { ... }
}Required Methods§
Provided Methods§
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
True if the container contains 0 elements.
use hexga_core::prelude::*;
assert_eq!([1, 2, 3].is_empty(), false);
let empty_array : [i32; 0] = [];
assert_eq!(empty_array.is_empty(), true);
assert_eq!("".is_empty(), true);
assert_eq!("hello".is_empty(), false);
assert_eq!("".is_empty(), !("".is_not_empty()));Sourcefn is_not_empty(&self) -> bool
fn is_not_empty(&self) -> bool
True if the container contains at least one element.
Will always be different than is_empty().
use hexga_core::prelude::*;
assert_eq!([1, 2, 3].is_not_empty(), true);
let empty_array : [i32; 0] = [];
assert_eq!(empty_array.is_not_empty(), false);
assert_eq!("".is_not_empty(), false);
assert_eq!("hello".is_not_empty(), true);
assert_eq!("".is_empty(), !("".is_not_empty()));