pub(crate) enum Repr<Prim, Packed> {
Transparent(Span),
Compound(Spanned<CompoundRepr<Prim>>, Option<Spanned<AlignRepr<Packed>>>),
}Expand description
The computed representation of a type.
This is the result of processing all #[repr(...)] attributes on a type, if
any. A Repr is only capable of representing legal combinations of
#[repr(...)] attributes.
Variants§
Transparent(Span)
#[repr(transparent)]
Compound(Spanned<CompoundRepr<Prim>>, Option<Spanned<AlignRepr<Packed>>>)
A compound representation: repr(C), repr(Rust), or repr(Int)
optionally combined with repr(packed(...)) or repr(align(...))
Implementations§
Source§impl<Prim, Packed> Repr<Prim, Packed>
impl<Prim, Packed> Repr<Prim, Packed>
Sourcepub(crate) fn repr_type_name(&self) -> &str
pub(crate) fn repr_type_name(&self) -> &str
Gets the name of this “repr type” - the non-align repr(X) that is used
in prose to refer to this type.
For example, we would refer to #[repr(C, align(4))] struct Foo { ... }
as a “repr(C) struct”.
pub(crate) fn is_transparent(&self) -> bool
pub(crate) fn is_c(&self) -> bool
pub(crate) fn is_primitive(&self) -> bool
pub(crate) fn get_packed(&self) -> Option<&Packed>
pub(crate) fn get_align(&self) -> Option<Spanned<NonZeroU32>>
pub(crate) fn is_align_gt_1(&self) -> bool
Sourcepub(crate) fn unaligned_validate_no_align_gt_1(&self) -> Result<(), Error>
pub(crate) fn unaligned_validate_no_align_gt_1(&self) -> Result<(), Error>
When deriving Unaligned, validate that the decorated type has no
#[repr(align(N))] attribute where N > 1. If no such attribute exists
(including if N == 1), this returns Ok(()), and otherwise it returns
a descriptive error.
Source§impl<Prim> Repr<Prim, NonZeroU32>
impl<Prim> Repr<Prim, NonZeroU32>
Sourcepub(crate) fn is_packed_1(&self) -> bool
pub(crate) fn is_packed_1(&self) -> bool
Does self describe a #[repr(packed)] or #[repr(packed(1))] type?
Source§impl<Packed> Repr<PrimitiveRepr, Packed>
impl<Packed> Repr<PrimitiveRepr, Packed>
fn get_primitive(&self) -> Option<&PrimitiveRepr>
Source§impl<Prim, Packed> Repr<Prim, Packed>
impl<Prim, Packed> Repr<Prim, Packed>
fn from_attrs_inner( attrs: &[Attribute], ) -> Result<Repr<Prim, Packed>, Spanned<FromAttrsError>>
Trait Implementations§
Source§impl<Prim, Packed> ToTokens for Repr<Prim, Packed>
impl<Prim, Packed> ToTokens for Repr<Prim, Packed>
Source§fn to_tokens(&self, ts: &mut TokenStream)
fn to_tokens(&self, ts: &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,
Auto Trait Implementations§
impl<Prim, Packed> Freeze for Repr<Prim, Packed>
impl<Prim, Packed> RefUnwindSafe for Repr<Prim, Packed>where
Prim: RefUnwindSafe,
Packed: RefUnwindSafe,
impl<Prim, Packed> !Send for Repr<Prim, Packed>
impl<Prim, Packed> !Sync for Repr<Prim, Packed>
impl<Prim, Packed> Unpin for Repr<Prim, Packed>
impl<Prim, Packed> UnwindSafe for Repr<Prim, Packed>where
Prim: UnwindSafe,
Packed: 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
Source§impl<T> Spanned for T
impl<T> Spanned for T
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.