Trait openapi_utils::ReferenceOrExt [−][src]
pub trait ReferenceOrExt<T> {
fn to_item(self) -> T;
fn to_item_ref(&self) -> &T;
fn to_item_mut(&mut self) -> &mut T;
}Expand description
This extension deals with ReferenceOr enums in the spec
All these methods assume the spec has been previously dereferenced,
see the deref_all method in the spec object.
These methods are still needed because structs hold ReferenceOr enums, although
these enums always have an item, never a reference.
Required methods
fn to_item_ref(&self) -> &T
fn to_item_ref(&self) -> &T
Returns reference to internal Item for a ReferenceOr
fn to_item_mut(&mut self) -> &mut T
fn to_item_mut(&mut self) -> &mut T
Returns mutable reference to internal Item for a ReferenceOr
Implementations on Foreign Types
to_item_* functions return the item of a reference without searching
These functions will panic if they find a reference. They
Are used as convenience methods in a document already dereferenced.
Examples
let item = ReferenceOr::Item(3);
assert_eq!(to_item(item), 3);Examples
let item = ReferenceOr::Item(3);
assert_eq!(to_item_ref(&item), &3);Examples
let mut item = ReferenceOr::Item(3);
assert_eq!(to_item_mut(&mut item), &3);