pub unsafe trait UniqueValue {
    // Required method
    fn get_unique(&self) -> Option<&str>;
}
Expand description

Return a reference to value in a collection if it is the only one.

For example, a vector of string like types returns a reference to its first element if there are no other, else it returns None.

If this were done with slices, that would require choosing a particular value type of the underlying slice e.g. [String].

Required Methods§

source

fn get_unique(&self) -> Option<&str>

Borrow the unique value reference.

Implementations on Foreign Types§

source§

impl UniqueValue for str

source§

impl<'a, V> UniqueValue for &'a Vwhere V: AsRef<str> + ?Sized,

source§

impl<V: UniqueValue + ?Sized> UniqueValue for Arc<V>

source§

impl<V: UniqueValue> UniqueValue for [V]

source§

impl<V: UniqueValue> UniqueValue for Option<V>

source§

impl UniqueValue for String

source§

impl<V: UniqueValue + ?Sized> UniqueValue for Box<V>

source§

impl<V: UniqueValue> UniqueValue for Vec<V>

source§

impl<V: UniqueValue + ?Sized> UniqueValue for Rc<V>

Implementors§

source§

impl<'a> UniqueValue for Cow<'a, str>