Enum openapiv3::ReferenceOr
source · pub enum ReferenceOr<T> {
Reference {
reference: String,
},
Item(T),
}
Variants§
Implementations§
source§impl<T> ReferenceOr<T>
impl<T> ReferenceOr<T>
pub fn ref_(r: &str) -> Self
pub fn boxed_item(item: T) -> ReferenceOr<Box<T>>
sourcepub fn into_item(self) -> Option<T>
pub fn into_item(self) -> Option<T>
Converts this ReferenceOr to the item inside, if it exists.
The return value will be Option::Some if this was a ReferenceOr::Item or Option::None if this was a ReferenceOr::Reference.
Examples
let i = ReferenceOr::Item(1);
assert_eq!(i.into_item(), Some(1));
let j: ReferenceOr<u8> = ReferenceOr::Reference { reference: String::new() };
assert_eq!(j.into_item(), None);
sourcepub fn as_item(&self) -> Option<&T>
pub fn as_item(&self) -> Option<&T>
Returns a reference to to the item inside this ReferenceOr, if it exists.
The return value will be Option::Some if this was a ReferenceOr::Item or Option::None if this was a ReferenceOr::Reference.
Examples
let i = ReferenceOr::Item(1);
assert_eq!(i.as_item(), Some(&1));
let j: ReferenceOr<u8> = ReferenceOr::Reference { reference: String::new() };
assert_eq!(j.as_item(), None);
source§impl<T> ReferenceOr<Box<T>>
impl<T> ReferenceOr<Box<T>>
pub fn unbox(self) -> ReferenceOr<T>
Trait Implementations§
source§impl<T: Clone> Clone for ReferenceOr<T>
impl<T: Clone> Clone for ReferenceOr<T>
source§fn clone(&self) -> ReferenceOr<T>
fn clone(&self) -> ReferenceOr<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 ReferenceOr<T>
impl<T: Debug> Debug for ReferenceOr<T>
source§impl<'de, T> Deserialize<'de> for ReferenceOr<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ReferenceOr<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: PartialEq> PartialEq<ReferenceOr<T>> for ReferenceOr<T>
impl<T: PartialEq> PartialEq<ReferenceOr<T>> for ReferenceOr<T>
source§fn eq(&self, other: &ReferenceOr<T>) -> bool
fn eq(&self, other: &ReferenceOr<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.