Skip to main content

non_empty

Macro non_empty 

Source
macro_rules! non_empty {
    (@$items:expr) => { ... };
    ($first:expr $(, $rest:expr)* $(,)?) => { ... };
}
Expand description

Creates a NonEmpty iterator from one or more items.

§Examples

use commonware_utils::non_empty;

let items = non_empty![1, 2, 3];
assert_eq!(items.into_iter().collect::<Vec<_>>(), vec![1, 2, 3]);

let items = non_empty![@1..4];
assert_eq!(items.into_iter().collect::<Vec<_>>(), vec![1, 2, 3]);
use commonware_utils::non_empty;

let empty = non_empty![];

§Panics

The @ form panics if the provided iterator is empty.