noneifempty

Trait NoneIfEmpty

Source
pub trait NoneIfEmpty
where 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§

Source

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

Converts a String to None if empty

Source§

impl<'s> NoneIfEmpty for &'s str

Converts a &str to None if empty

Source§

impl<K, V> NoneIfEmpty for HashMap<K, V>

Converts a HashMap to None if empty

Source§

impl<N: NoneIfEmpty> NoneIfEmpty for Option<N>

Automatically implement NoneIfEmpty for Option<T: NoneIfEmpty>

This is basically a flatten

Source§

impl<T> NoneIfEmpty for Vec<T>

Converts a Vec to None if empty

Source§

impl<T> NoneIfEmpty for HashSet<T>

Converts a HashSet to None if empty

Implementors§