Enum schemars::schema::SingleOrVec
source · [−]Expand description
A type which can be serialized as a single item, or multiple items.
In some contexts, a Single
may be semantically distinct from a Vec
containing only item.
Variants
Single(Box<T>)
Vec(Vec<T>)
Implementations
sourceimpl<T: PartialEq> SingleOrVec<T>
impl<T: PartialEq> SingleOrVec<T>
sourcepub fn contains(&self, x: &T) -> bool
pub fn contains(&self, x: &T) -> bool
Returns true
if self
is either a Single
equal to x
, or a Vec
containing x
.
Examples
use schemars::schema::SingleOrVec;
let s = SingleOrVec::from(10);
assert!(s.contains(&10));
assert!(!s.contains(&20));
let v = SingleOrVec::from(vec![10, 20]);
assert!(v.contains(&10));
assert!(v.contains(&20));
assert!(!v.contains(&30));
Trait Implementations
sourceimpl<T: Clone> Clone for SingleOrVec<T>
impl<T: Clone> Clone for SingleOrVec<T>
sourcefn clone(&self) -> SingleOrVec<T>
fn clone(&self) -> SingleOrVec<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for SingleOrVec<T>
impl<T: Debug> Debug for SingleOrVec<T>
sourceimpl<'de, T> Deserialize<'de> for SingleOrVec<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for SingleOrVec<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> From<T> for SingleOrVec<T>
impl<T> From<T> for SingleOrVec<T>
sourceimpl<T> From<Vec<T, Global>> for SingleOrVec<T>
impl<T> From<Vec<T, Global>> for SingleOrVec<T>
sourceimpl<T: Ord> Ord for SingleOrVec<T>
impl<T: Ord> Ord for SingleOrVec<T>
sourceimpl<T: PartialEq> PartialEq<SingleOrVec<T>> for SingleOrVec<T>
impl<T: PartialEq> PartialEq<SingleOrVec<T>> for SingleOrVec<T>
sourcefn eq(&self, other: &SingleOrVec<T>) -> bool
fn eq(&self, other: &SingleOrVec<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SingleOrVec<T>) -> bool
fn ne(&self, other: &SingleOrVec<T>) -> bool
This method tests for !=
.
sourceimpl<T: PartialOrd> PartialOrd<SingleOrVec<T>> for SingleOrVec<T>
impl<T: PartialOrd> PartialOrd<SingleOrVec<T>> for SingleOrVec<T>
sourcefn partial_cmp(&self, other: &SingleOrVec<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &SingleOrVec<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T> Serialize for SingleOrVec<T> where
T: Serialize,
impl<T> Serialize for SingleOrVec<T> where
T: Serialize,
impl<T: Eq> Eq for SingleOrVec<T>
impl<T> StructuralEq for SingleOrVec<T>
impl<T> StructuralPartialEq for SingleOrVec<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for SingleOrVec<T> where
T: RefUnwindSafe,
impl<T> Send for SingleOrVec<T> where
T: Send,
impl<T> Sync for SingleOrVec<T> where
T: Sync,
impl<T> Unpin for SingleOrVec<T> where
T: Unpin,
impl<T> UnwindSafe for SingleOrVec<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more