Skip to main content

StructDef

Struct StructDef 

pub struct StructDef {
    pub name: String,
    pub fields: Vec<StructField>,
    pub posture: Posture,
    pub is_clone: bool,
    pub thread_safety: ThreadSafety,
    pub destructor: Option<String>,
    pub is_builtin: bool,
    pub is_pub: bool,
    pub file_id: FileId,
    pub is_c_layout: bool,
}
Expand description

Definition of a struct type.

Fields§

§name: String

Struct name

§fields: Vec<StructField>

Fields in declaration order

§posture: Posture

Final ownership posture (ADR-0080). Decides whether values of this struct are Copy, Affine (default — move on use, implicit drop), or Linear (must be explicitly consumed). Set by register_type_names from the declared keyword/@mark(...), then filled in from structural inference for unmarked types.

§is_clone: bool

Whether this struct is marked with @derive(Clone) (compiler-synthesized recursive clone). ADR-0065. Independent of posture: every Copy type is automatically Clone, but @derive(Clone) can also be applied to affine types whose fields are all Clone.

§thread_safety: ThreadSafety

ADR-0084: final thread-safety classification (Unsend < Send < Sync). Computed during validate_consistency as the structural minimum over fields, then overridden by any @mark(unsend) / @mark(checked_send) / @mark(checked_sync) directive on the declaration. Until that pass runs, the value reflects only the declared override (or Sync if none); call TypeInternPool::is_thread_safety_type for the load-bearing query rather than reading this field directly.

§destructor: Option<String>

User-defined destructor function name, if any (e.g., “Data.__drop”)

§is_builtin: bool

Whether this is a built-in type (e.g., String) injected by the compiler.

Built-in types behave like regular structs but have runtime implementations for their methods rather than generated code.

§is_pub: bool

Whether this struct is public (visible outside its directory)

§file_id: FileId

File ID this struct was declared in (for visibility checking)

§is_c_layout: bool

ADR-0085: whether @mark(c) was applied — selects C layout (declaration-order fields, natural alignment, niche optimisation disabled) and makes the type eligible to cross the FFI boundary by value.

Implementations§

§

impl StructDef

pub fn is_tuple_shaped(&self) -> bool

Returns true if this struct was synthesised to represent a tuple (ADR-0048): fields named “0”, “1”, …, “N-1”, in order, no methods, and the anon-struct name prefix.

pub fn tuple_display_name<F>(&self, fmt_ty: F) -> Option<String>
where F: FnMut(Type) -> String,

If this struct is tuple-shaped, render its tuple-syntax name: (T0, T1, ...) for arity ≥ 2, (T0,) for arity 1. The formatter is passed a callback to render each field type name.

§

impl StructDef

pub fn find_field(&self, name: &str) -> Option<(usize, &StructField)>

Find a field by name and return its index and definition.

pub fn field_count(&self) -> usize

Get the number of fields in this struct.

Trait Implementations§

§

impl Clone for StructDef

§

fn clone(&self) -> StructDef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for StructDef

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for StructDef

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<StructDef, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Serialize for StructDef

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,