Enum schemars::schema::SingleOrVec
source · pub enum SingleOrVec<T> {
Single(Box<T>),
Vec(Vec<T>),
}
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§
Implementations§
source§impl<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§
source§impl<T: Clone> Clone for SingleOrVec<T>
impl<T: Clone> Clone for SingleOrVec<T>
source§fn clone(&self) -> SingleOrVec<T>
fn clone(&self) -> SingleOrVec<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for SingleOrVec<T>
impl<T: Debug> Debug for SingleOrVec<T>
source§impl<'de, T> Deserialize<'de> for SingleOrVec<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for SingleOrVec<T>where
T: Deserialize<'de>,
source§fn 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
source§impl<T> From<T> for SingleOrVec<T>
impl<T> From<T> for SingleOrVec<T>
source§impl<T> From<Vec<T>> for SingleOrVec<T>
impl<T> From<Vec<T>> for SingleOrVec<T>
source§impl<T: Ord> Ord for SingleOrVec<T>
impl<T: Ord> Ord for SingleOrVec<T>
source§fn cmp(&self, other: &SingleOrVec<T>) -> Ordering
fn cmp(&self, other: &SingleOrVec<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq> PartialEq for SingleOrVec<T>
impl<T: PartialEq> PartialEq for SingleOrVec<T>
source§impl<T: PartialOrd> PartialOrd for SingleOrVec<T>
impl<T: PartialOrd> PartialOrd for SingleOrVec<T>
source§impl<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> StructuralPartialEq for SingleOrVec<T>
Auto Trait Implementations§
impl<T> Freeze for SingleOrVec<T>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.