pub trait NoneIfEmptywhere
Self: Sized,{
type Output;
// Required method
fn none_if_empty(self) -> Option<Self::Output>;
}
Expand description
Trait for converting an empty T to None
Required Associated Types§
Required Methods§
fn none_if_empty(self) -> Option<Self::Output>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl NoneIfEmpty for String
impl NoneIfEmpty for String
Converts a String to None if empty
Source§impl<'s> NoneIfEmpty for &'s str
impl<'s> NoneIfEmpty for &'s str
Converts a &str to None if empty
Source§impl<K, V> NoneIfEmpty for HashMap<K, V>
impl<K, V> NoneIfEmpty for HashMap<K, V>
Converts a HashMap to None if empty
Source§impl<N: NoneIfEmpty> NoneIfEmpty for Option<N>
impl<N: NoneIfEmpty> NoneIfEmpty for Option<N>
Automatically implement NoneIfEmpty for Option<T: NoneIfEmpty>
This is basically a flatten
type Output = <N as NoneIfEmpty>::Output
fn none_if_empty(self) -> Option<Self::Output>
Source§impl<T> NoneIfEmpty for Vec<T>
impl<T> NoneIfEmpty for Vec<T>
Converts a Vec to None if empty
Source§impl<T> NoneIfEmpty for HashSet<T>
impl<T> NoneIfEmpty for HashSet<T>
Converts a HashSet to None if empty