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: StringStruct name
fields: Vec<StructField>Fields in declaration order
posture: PostureFinal 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: boolWhether 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: ThreadSafetyADR-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: boolWhether 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: boolWhether this struct is public (visible outside its directory)
file_id: FileIdFile ID this struct was declared in (for visibility checking)
is_c_layout: boolADR-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
impl StructDef
pub fn is_tuple_shaped(&self) -> bool
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.
§impl StructDef
impl StructDef
pub fn find_field(&self, name: &str) -> Option<(usize, &StructField)>
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
pub fn field_count(&self) -> usize
Get the number of fields in this struct.
Trait Implementations§
§impl<'de> Deserialize<'de> for StructDef
impl<'de> Deserialize<'de> for StructDef
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StructDef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StructDef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for StructDef
impl Serialize for StructDef
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for StructDef
impl RefUnwindSafe for StructDef
impl Send for StructDef
impl Sync for StructDef
impl Unpin for StructDef
impl UnsafeUnpin for StructDef
impl UnwindSafe for StructDef
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].