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 const fn is_borrowed(&self) -> bool
pub const fn is_borrowed(&self) -> bool
Check if Self
contains a borrowed type
Inverse of MaybeBorrowed::is_owned
.
Sourcepub const fn is_owned(&self) -> bool
pub const 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>
impl<'a, Gen> AttachGenerics<'a> for MaybeBorrowed<'a, Gen>
Source§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>
Source§fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>
fn with_generics<G>(self, generics: G) -> WithGenerics<'a, Self::Output>
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, U> From<&'a U> for MaybeBorrowed<'a, StaticTid<TokenCmpWrapper<U>>>where
U: ToTokens,
impl<'a, U> From<&'a U> for MaybeBorrowed<'a, StaticTid<TokenCmpWrapper<U>>>where
U: ToTokens,
Source§impl<'a, U> From<&'a U> for MaybeBorrowed<'a, TokenCmpWrapper<StaticTid<U>>>where
U: ToTokens,
impl<'a, U> From<&'a U> for MaybeBorrowed<'a, TokenCmpWrapper<StaticTid<U>>>where
U: ToTokens,
Source§impl<'a, U> From<&'a U> for MaybeBorrowed<'a, TokenCmpWrapper<U>>where
U: ToTokens,
impl<'a, U> From<&'a U> for MaybeBorrowed<'a, TokenCmpWrapper<U>>where
U: ToTokens,
Source§impl<'a, T> From<T> for MaybeBorrowed<'a, StaticTid<T>>
impl<'a, T> From<T> for MaybeBorrowed<'a, StaticTid<T>>
Source§impl<'a, T> From<T> for MaybeBorrowed<'a, T>
impl<'a, T> From<T> for MaybeBorrowed<'a, T>
Source§impl<'a, T> From<T> for MaybeBorrowed<'a, TokenCmpWrapper<T>>where
T: ToTokens,
impl<'a, T> From<T> for MaybeBorrowed<'a, TokenCmpWrapper<T>>where
T: ToTokens,
Source§impl<'a, U> From<U> for MaybeBorrowed<'a, StaticTid<TokenCmpWrapper<U>>>where
U: ToTokens,
impl<'a, U> From<U> for MaybeBorrowed<'a, StaticTid<TokenCmpWrapper<U>>>where
U: ToTokens,
Source§impl<'a, U> From<U> for MaybeBorrowed<'a, TokenCmpWrapper<StaticTid<U>>>where
U: ToTokens,
impl<'a, U> From<U> for MaybeBorrowed<'a, TokenCmpWrapper<StaticTid<U>>>where
U: 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 for MaybeBorrowed<'a, T>where
T: PartialEq,
impl<'a, T> PartialEq for MaybeBorrowed<'a, T>where
T: PartialEq,
Source§impl<'a, T> PartialOrd for MaybeBorrowed<'a, T>where
T: PartialOrd,
impl<'a, T> PartialOrd for MaybeBorrowed<'a, T>where
T: PartialOrd,
Source§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,
impl<'a, T> TidAble<'a> for MaybeBorrowed<'a, T>where
T: TidAble<'a>,
Auto Trait Implementations§
impl<'a, T> Freeze for MaybeBorrowed<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for MaybeBorrowed<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for MaybeBorrowed<'a, T>
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 T
impl<T> AnyExt for T
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>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T
behind Rc
pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>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.Source§impl<'a, X> TidExt<'a> for X
impl<'a, X> TidExt<'a> for X
Source§fn is<T>(&self) -> boolwhere
T: Tid<'a>,
fn is<T>(&self) -> boolwhere
T: Tid<'a>,
Returns true if type behind self is equal to the type of T.
Source§fn downcast_ref<'b, T>(&'b self) -> Option<&'b T>where
T: Tid<'a>,
fn downcast_ref<'b, T>(&'b self) -> Option<&'b T>where
T: Tid<'a>,
Attempts to downcast self to
T
behind referenceSource§fn downcast_mut<'b, T>(&'b mut self) -> Option<&'b mut T>where
T: Tid<'a>,
fn downcast_mut<'b, T>(&'b mut self) -> Option<&'b mut T>where
T: Tid<'a>,
Attempts to downcast self to
T
behind mutable referenceSource§fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Tid<'a>,
fn downcast_rc<T>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Tid<'a>,
Attempts to downcast self to
T
behind Rc
pointerSource§fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Tid<'a>,
fn downcast_arc<T>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Tid<'a>,
Attempts to downcast self to
T
behind Arc
pointer