pub enum MaybeBorrowed<'a, T> {
    Borrowed(&'a T),
    Owned(T),
}
Expand description

Some type that is eiher borrowed or owned

Variants§

§

Borrowed(&'a T)

Some borrowed type

§

Owned(T)

Some owned type

Implementations§

source§

impl<'a, T> MaybeBorrowed<'a, T>

source

pub fn is_borrowed(&self) -> bool

Check if Self contains a borrowed type Inverse of MaybeBorrowed::is_owned.

source

pub fn is_owned(&self) -> bool

Check if Self contains a owned type. Inverse of MaybeBorrowed::is_borrowed.

Trait Implementations§

source§

impl<'a, Gen> AttachGenerics<'a> for MaybeBorrowed<'a, Gen>where Gen: Generatable<'a>,

§

type Output = MaybeBorrowed<'a, Gen>

An optional type wrapper around the type the generics will be attached to Used by this crate to wrap types with MaybeBorrowed to allow both references and owned types to be represented by the same type.
source§

fn with_optional_generics<G>( self, generics: Option<G> ) -> WithGenerics<'a, Self::Output>where G: Into<MaybeBorrowed<'a, Generics>>,

source§

fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>where G: Into<MaybeBorrowed<'a, Generics>>, Self: Sized,

Attach some generics G to Self. This allows for the generics to to not exactly be syn::Generics but any type that can be turned into MaybeBorrowed<syn::Generics>. This allows for both &syn::Generics and syn::Generics to be attached using the same trait.
source§

impl<'a, T: Debug> Debug for MaybeBorrowed<'a, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T> Deref for MaybeBorrowed<'a, T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, T> From<&'a T> for MaybeBorrowed<'a, T>

source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<&'a T> for MaybeBorrowed<'a, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where MaybeBorrowed<'a, T>: ToTokens,

source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<T> for MaybeBorrowed<'a, T>

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T> From<T> for MaybeBorrowed<'b, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where MaybeBorrowed<'a, T>: ToTokens,

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl<'a, T> Hash for MaybeBorrowed<'a, T>where T: Hash,

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, T> Ord for MaybeBorrowed<'a, T>where T: Ord,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<'a, T> PartialEq<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where T: PartialEq,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> PartialOrd<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> ToTokens for MaybeBorrowed<'a, T>where T: ToTokens,

source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStreamwhere Self: Sized,

Convert self directly into a TokenStream object. Read more
source§

impl<'a, T> Eq for MaybeBorrowed<'a, T>where T: Eq,

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for MaybeBorrowed<'a, T>where T: RefUnwindSafe,

§

impl<'a, T> Send for MaybeBorrowed<'a, T>where T: Send + Sync,

§

impl<'a, T> Sync for MaybeBorrowed<'a, T>where T: Sync,

§

impl<'a, T> Unpin for MaybeBorrowed<'a, T>where T: Unpin,

§

impl<'a, T> UnwindSafe for MaybeBorrowed<'a, T>where T: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyExt for Twhere T: Any + ?Sized,

source§

fn downcast_ref<T>(this: &Self) -> Option<&T>where T: Any,

Attempts to downcast this to T behind reference
source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where T: Any,

Attempts to downcast this to T behind mutable reference
source§

fn downcast_rc<T>( this: Rc<Self, Global> ) -> Result<Rc<T, Global>, Rc<Self, Global>>where T: Any,

Attempts to downcast this to T behind Rc pointer
source§

fn downcast_arc<T>( this: Arc<Self, Global> ) -> Result<Arc<T, Global>, Arc<Self, Global>>where T: Any,

Attempts to downcast this to T behind Arc pointer
source§

fn downcast_box<T>( this: Box<Self, Global> ) -> Result<Box<T, Global>, Box<Self, Global>>where T: Any,

Attempts to downcast this to T behind Box pointer
source§

fn downcast_move<T>(this: Self) -> Option<T>where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<'a, T, U> ResolveBounds<'a, T> for Uwhere T: AssertableWithBounds<'a, U> + 'a,

source§

fn resolve_for( self, assertable: impl Into<MaybeBorrowed<'a, T>> ) -> ResolvedBounds<'a, U, T>

source§

impl<T> Spanned for Twhere T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TypeEq for Twhere T: ?Sized,

§

type This = T