pub type IsEmpty<List> = <List as TList>::IsEmpty;
Available on crate feature
typenum
only.Expand description
Type-level ‘function’ returning typenum::B1
when the list is empty; typenum::B0
otherwise.
You can turn the result into a bool
using IsEmpty<List>::BOOL
or IsEmpty<List>::to_bool()
.
(See typenum::Bit
for more on this.)
use tlist::*;
use typenum::{B0, B1, Bit};
use static_assertions::assert_type_eq_all as assert_type_eq;
assert_type_eq!(IsEmpty<TList![]>, B1);
assert_type_eq!(IsEmpty<TList![i32]>, B0);
assert_type_eq!(IsEmpty<TList![u32, i64]>, B0);
assert_eq!(IsEmpty::<TList![]>::BOOL, true);
assert_eq!(IsEmpty::<TList![&'static str]>::BOOL, false);
IsEmpty is a type-level function that works for any TList, returning a type-level boolean. If you want to constrain what kind of TList is allowed for a certain operation, use the Empty or NonEmpty constraining traits.