pub enum RefOr<T> {
Reference {
reference: String,
},
Item(T),
}
Variants§
Implementations§
Source§impl<T> RefOr<T>
impl<T> RefOr<T>
pub fn ref_(r: &str) -> RefOr<T>
pub fn schema_ref(r: &str) -> RefOr<T>
pub fn boxed(self) -> Box<RefOr<T>>
Sourcepub fn into_item(self) -> Option<T>
pub fn into_item(self) -> Option<T>
Converts this RefOr to the item inside, if it exists.
The return value will be Option::Some if this was a RefOr::Item or Option::None if this was a RefOr::Reference.
§Examples
let i = RefOr::Item(1);
assert_eq!(i.into_item(), Some(1));
let j: RefOr<u8> = RefOr::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 RefOr, if it exists.
The return value will be Option::Some if this was a RefOr::Item or Option::None if this was a RefOr::Reference.
§Examples
let i = RefOr::Item(1);
assert_eq!(i.as_item(), Some(&1));
let j: RefOr<u8> = RefOr::Reference { reference: String::new() };
assert_eq!(j.as_item(), None);
pub fn as_ref_str(&self) -> Option<&str>
pub fn as_mut(&mut self) -> Option<&mut T>
pub fn to_mut(&mut self) -> &mut T
Source§impl RefOr<RequestBody>
impl RefOr<RequestBody>
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for RefOr<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for RefOr<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RefOr<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RefOr<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Serialize for RefOr<T>where
T: Serialize,
impl<T> Serialize for RefOr<T>where
T: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T> StructuralPartialEq for RefOr<T>
Auto Trait Implementations§
impl<T> Freeze for RefOr<T>where
T: Freeze,
impl<T> RefUnwindSafe for RefOr<T>where
T: RefUnwindSafe,
impl<T> Send for RefOr<T>where
T: Send,
impl<T> Sync for RefOr<T>where
T: Sync,
impl<T> Unpin for RefOr<T>where
T: Unpin,
impl<T> UnwindSafe for RefOr<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