HasSome

Trait HasSome 

Source
pub trait HasSome {
    // Required methods
    fn has_some(&self) -> bool;
    fn is_empty2(self: &&Self) -> bool;

    // Provided methods
    fn is_empty3(self: &&&Self) -> bool { ... }
    fn has_some2(self: &&Self) -> bool { ... }
    fn has_some3(self: &&&Self) -> bool { ... }
}

Required Methods§

Source

fn has_some(&self) -> bool

The opposite to T:is_empty.

Usually implemented as !self.is_empty(), but as that method is not defined by a Trait in stable Rust, this needs re-implementing for each type that requires it.

§Examples
use has_some::HasSome;

assert!("this is not empty".has_some());
use has_some::HasSome;
let vector = vec!["some_data".to_owned(), "".to_owned(), "more data".to_owned()];

let not_empties: Vec<String> = vector.into_iter().filter(String::has_some).collect();

assert_eq!(["some_data","more data"], not_empties.as_slice());
Source

fn is_empty2(self: &&Self) -> bool

is_empty in a form that is suitable for use in Iterator::filter where Item = &OwnedType (e.g. &String)

§Examples
use has_some::HasSome;
let vector = vec!["some_data".to_owned(), "".to_owned(), "more data".to_owned()];

let empties: Vec<&String> = vector.iter().filter(String::is_empty2).collect();

assert_eq!([""], empties.as_slice());

Provided Methods§

Source

fn is_empty3(self: &&&Self) -> bool

is_empty in a form that is suitable for use in Iterator::filter where Item = &RefType (e.g. &&str)

§Examples
use has_some::HasSome;
let vector = vec!["some_data", "", "more data"];

let empties: Vec<&&str> = vector.iter().filter(str::is_empty3).collect();

assert_eq!([&""], empties.as_slice());
Source

fn has_some2(self: &&Self) -> bool

has_some in a form that is suitable for use in Iterator::filter where Item = &OwnedType (e.g. &String)

§Examples
use has_some::HasSome;
let vector = vec!["some_data".to_owned(), "".to_owned(), "more data".to_owned()];

let not_empties: Vec<&String> = vector.iter().filter(String::has_some2).collect();

assert_eq!(["some_data","more data"], not_empties.as_slice());
Source

fn has_some3(self: &&&Self) -> bool

has_some in a form that is suitable for use in Iterator::filter where Item = &RefType (e.g. &&str)

§Examples
use has_some::HasSome;
let vector = vec!["some_data", "", "more data"];

let not_empties: Vec<&&str> = vector.iter().filter(str::has_some3).collect();

assert_eq!([&"some_data", &"more data"], not_empties.as_slice());

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 HasSome for str

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl HasSome for String

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl HasSome for CStr

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<Idx: PartialOrd<Idx>> HasSome for Range<Idx>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<Idx: PartialOrd<Idx>> HasSome for RangeInclusive<Idx>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

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

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<K, V, S: BuildHasher> HasSome for HashMap<K, V, S>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for [T]

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for BinaryHeap<T>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for BTreeSet<T>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for LinkedList<T>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for VecDeque<T>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T> HasSome for Vec<T>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Source§

impl<T, S: BuildHasher> HasSome for HashSet<T, S>

Source§

fn has_some(&self) -> bool

Source§

fn is_empty2(self: &&Self) -> bool

Implementors§