pub enum OneOrMany<T> {
One(T),
Many(Vec<T>),
}
Expand description
Represents either a single value, or multiple values of T. Useful for differentiating between an array of length 1 and a single value.
Variants§
Implementations§
Source§impl<T> OneOrMany<T>
impl<T> OneOrMany<T>
Sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Canonicalizes self by:
- Transforming to ::One() if is_many() but len() == 1
- Sorting items if is_many()
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OneOrMany<Name>
impl<'de> Deserialize<'de> for OneOrMany<Name>
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<'de> Deserialize<'de> for OneOrMany<EventScope>
impl<'de> Deserialize<'de> for OneOrMany<EventScope>
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<'de> Deserialize<'de> for OneOrMany<ExposeFromRef>
impl<'de> Deserialize<'de> for OneOrMany<ExposeFromRef>
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<'de> Deserialize<'de> for OneOrMany<OfferFromRef>
impl<'de> Deserialize<'de> for OneOrMany<OfferFromRef>
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<'de> Deserialize<'de> for OneOrMany<OfferToRef>
impl<'de> Deserialize<'de> for OneOrMany<OfferToRef>
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<'de> Deserialize<'de> for OneOrMany<Path>
impl<'de> Deserialize<'de> for OneOrMany<Path>
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> FromIterator<T> for OneOrMany<T>
impl<T> FromIterator<T> for OneOrMany<T>
Source§impl<'a, T> IntoIterator for &'a OneOrMany<T>
impl<'a, T> IntoIterator for &'a OneOrMany<T>
Source§impl<T> IntoIterator for OneOrMany<T>
impl<T> IntoIterator for OneOrMany<T>
Source§impl<T: Ord> Ord for OneOrMany<T>
impl<T: Ord> Ord for OneOrMany<T>
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: PartialOrd> PartialOrd for OneOrMany<T>
impl<T: PartialOrd> PartialOrd for OneOrMany<T>
Source§impl Serialize for OneOrMany<EventScope>
impl Serialize for OneOrMany<EventScope>
Source§impl Serialize for OneOrMany<ExposeFromRef>
impl Serialize for OneOrMany<ExposeFromRef>
Source§impl Serialize for OneOrMany<OfferFromRef>
impl Serialize for OneOrMany<OfferFromRef>
Source§impl Serialize for OneOrMany<OfferToRef>
impl Serialize for OneOrMany<OfferToRef>
impl<T: Eq> Eq for OneOrMany<T>
Auto Trait Implementations§
impl<T> Freeze for OneOrMany<T>where
T: Freeze,
impl<T> RefUnwindSafe for OneOrMany<T>where
T: RefUnwindSafe,
impl<T> Send for OneOrMany<T>where
T: Send,
impl<T> Sync for OneOrMany<T>where
T: Sync,
impl<T> Unpin for OneOrMany<T>where
T: Unpin,
impl<T> UnwindSafe for OneOrMany<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<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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.