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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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.