Skip to main content

Length

Trait Length 

Source
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§

Source

fn len(&self) -> usize

Provided Methods§

Source

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()));
Source

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()));

Implementations on Foreign Types§

Source§

impl Length for &str

Source§

fn len(&self) -> usize

Source§

impl Length for &mut str

Source§

fn len(&self) -> usize

Source§

impl Length for str

Source§

fn len(&self) -> usize

Source§

impl Length for String

Source§

fn len(&self) -> usize

Source§

impl Length for OsStr

Available on crate feature std only.
Source§

fn len(&self) -> usize

Source§

impl<T> Length for &[T]

Source§

fn len(&self) -> usize

Source§

impl<T> Length for &mut [T]

Source§

fn len(&self) -> usize

Source§

impl<T> Length for [T]

Source§

fn len(&self) -> usize

Source§

impl<T> Length for LinkedList<T>

Source§

fn len(&self) -> usize

Source§

impl<T> Length for Vec<T>

Source§

fn len(&self) -> usize

Source§

impl<T, const CAP: usize> Length for ArrayVec<T, CAP>

Source§

fn len(&self) -> usize

Source§

impl<T, const N: usize> Length for [T; N]

Source§

fn len(&self) -> usize

Implementors§

Source§

impl<K, Gen, S> Length for GenSetOf<K, Gen, S>
where K: Clone, Gen: IGeneration, S: Collection,

Source§

impl<K, V> Length for BTreeMap<K, V>

Source§

impl<K, V, Gen, S> Length for GenMapOf<K, V, Gen, S>
where K: Clone, Gen: IGeneration, S: Collection,

Source§

impl<K, V, S> Length for HashMap<K, V, S>

Available on crate feature std only.
Source§

impl<T> Length for BTreeSet<T>

Source§

impl<T> Length for BinaryHeap<T>

Source§

impl<T> Length for HslaOf<T>

Source§

impl<T> Length for NonEmptyStack<T>

Source§

impl<T> Length for RgbaOf<T>

Source§

impl<T> Length for VecDeque<T>

Source§

impl<T> Length for RectangleOf<T>

Source§

impl<T, Gen, C> Length for GenSeq<T, Gen, C>
where C: AsRef<[Entry<T, Gen>]>, Gen: IGeneration,

Source§

impl<T, Idx> Length for ImageBaseOf<T, Idx>
where Idx: Integer,

Source§

impl<T, Idx, const N: usize> Length for GridOf<T, Idx, N>
where Idx: Integer,

Source§

impl<T, S> Length for HashSet<T, S>

Available on crate feature std only.
Source§

impl<T, const N: usize> Length for Vector<T, N>