pub enum MaybeBorrowed<'a, T> {
Borrowed(&'a T),
Owned(T),
}
Expand description
Some type that is eiher borrowed or owned
Variants§
Implementations§
source§impl<'a, T> MaybeBorrowed<'a, T>
impl<'a, T> MaybeBorrowed<'a, T>
sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Check if Self
contains a borrowed type
Inverse of MaybeBorrowed::is_owned
.
sourcepub fn is_owned(&self) -> bool
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>,
impl<'a, Gen> AttachGenerics<'a> for MaybeBorrowed<'a, Gen>where Gen: Generatable<'a>,
§type Output = MaybeBorrowed<'a, Gen>
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.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,
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>
impl<'a, T: Debug> Debug for MaybeBorrowed<'a, T>
source§impl<'a, T> Deref for MaybeBorrowed<'a, T>
impl<'a, T> Deref for MaybeBorrowed<'a, T>
source§impl<'a, T> From<&'a T> for MaybeBorrowed<'a, T>
impl<'a, T> From<&'a T> for MaybeBorrowed<'a, T>
source§impl<'a, T> From<&'a T> for MaybeBorrowed<'a, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where
MaybeBorrowed<'a, T>: ToTokens,
impl<'a, T> From<&'a T> for MaybeBorrowed<'a, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where MaybeBorrowed<'a, T>: ToTokens,
source§impl<'a, T> From<T> for MaybeBorrowed<'a, T>
impl<'a, T> From<T> for MaybeBorrowed<'a, T>
source§impl<'a, 'b, T> From<T> for MaybeBorrowed<'b, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where
MaybeBorrowed<'a, T>: ToTokens,
impl<'a, 'b, T> From<T> for MaybeBorrowed<'b, TokenCmpWrapper<MaybeBorrowed<'a, T>>>where MaybeBorrowed<'a, T>: ToTokens,
source§impl<'a, T> Hash for MaybeBorrowed<'a, T>where
T: Hash,
impl<'a, T> Hash for MaybeBorrowed<'a, T>where T: Hash,
source§impl<'a, T> Ord for MaybeBorrowed<'a, T>where
T: Ord,
impl<'a, T> Ord for MaybeBorrowed<'a, T>where T: Ord,
source§impl<'a, T> PartialEq<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where
T: PartialEq,
impl<'a, T> PartialEq<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where T: PartialEq,
source§impl<'a, T> PartialOrd<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where
T: PartialOrd,
impl<'a, T> PartialOrd<MaybeBorrowed<'a, T>> for MaybeBorrowed<'a, T>where T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<'a, T> ToTokens for MaybeBorrowed<'a, T>where
T: ToTokens,
impl<'a, T> ToTokens for MaybeBorrowed<'a, T>where T: ToTokens,
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere Self: Sized,
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> AnyExt for Twhere
T: Any + ?Sized,
impl<T> AnyExt for Twhere T: Any + ?Sized,
source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where T: Any,
Attempts to downcast this to
T
behind referencesource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where T: Any,
Attempts to downcast this to
T
behind mutable referencesource§fn downcast_rc<T>(
this: Rc<Self, Global>
) -> Result<Rc<T, Global>, Rc<Self, Global>>where
T: Any,
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
pointersource§fn downcast_arc<T>(
this: Arc<Self, Global>
) -> Result<Arc<T, Global>, Arc<Self, Global>>where
T: Any,
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
pointersource§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<'a, T, U> ResolveBounds<'a, T> for Uwhere
T: AssertableWithBounds<'a, U> + 'a,
impl<'a, T, U> ResolveBounds<'a, T> for Uwhere T: AssertableWithBounds<'a, U> + 'a,
fn resolve_for( self, assertable: impl Into<MaybeBorrowed<'a, T>> ) -> ResolvedBounds<'a, U, T>
source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere T: Spanned + ?Sized,
source§fn span(&self) -> Span
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.