pub struct Struct {
pub fields: BTreeMap<SmolStr, Type>,
pub field_defaults: BTreeMap<SmolStr, ConstantExpression>,
pub name: StructName,
}Fields§
§fields: BTreeMap<SmolStr, Type>§field_defaults: BTreeMap<SmolStr, ConstantExpression>Default values for the fields.
The expressions are resolved, converted to the field type, and constant-folded.
Like the syntax node in name, this is ignored by Type’s equality comparison.
name: StructNameImplementations§
Source§impl Struct
impl Struct
Sourcepub fn new(fields: BTreeMap<SmolStr, Type>, name: impl Into<StructName>) -> Self
pub fn new(fields: BTreeMap<SmolStr, Type>, name: impl Into<StructName>) -> Self
Create a struct without declared field default values.
Sourcepub fn node(&self) -> Option<&SourceLocation>
pub fn node(&self) -> Option<&SourceLocation>
Where a user-declared struct was written (for the language server).
Sourcepub fn rust_attributes(&self) -> &[SmolStr]
pub fn rust_attributes(&self) -> &[SmolStr]
The raw text of each @rust-attr(...) on a user-declared struct.
Sourcepub fn field_order(&self) -> &[SmolStr]
pub fn field_order(&self) -> &[SmolStr]
The field names in declaration order for a user-declared struct.
Sourcepub fn default_value_for_field(&self, name: &SmolStr) -> Expression
pub fn default_value_for_field(&self, name: &SmolStr) -> Expression
The default value for the given field: the user-declared default if there is one, otherwise the default value for the field’s type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Struct
impl RefUnwindSafe for Struct
impl Send for Struct
impl Sync for Struct
impl Unpin for Struct
impl UnsafeUnpin for Struct
impl UnwindSafe for Struct
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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 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> ⓘ
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