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 moresourceimpl<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: JsonSchema> JsonSchema for SingleOrVec<T>
impl<T: JsonSchema> JsonSchema for SingleOrVec<T>
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresourceimpl<T: Ord> Ord for SingleOrVec<T>
impl<T: Ord> Ord for SingleOrVec<T>
sourcefn cmp(&self, other: &SingleOrVec<T>) -> Ordering
fn cmp(&self, other: &SingleOrVec<T>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
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
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>
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 moresourceimpl<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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.