pub struct StructDef {
pub name: StrId,
pub parent: Option<TypeId>,
pub fields: Vec<Field>,
pub methods: Vec<Method>,
}Expand description
A struct (record) type.
Field slots are numbered across the parent chain: a struct’s field list
begins with its parent’s fields, so a child instance can be used wherever
the parent is expected. Methods are looked up by name by
Inst::GetProp, the struct’s own first, then the
parent’s.
§Examples
use bytecode_lang::{Field, StrId, StructDef, ValType};
let point = StructDef {
name: StrId(0),
parent: None,
fields: vec![Field { name: StrId(1), ty: ValType::F64 }, Field { name: StrId(2), ty: ValType::F64 }],
methods: vec![],
};
assert_eq!(point.fields.len(), 2);Fields§
§name: StrIdThe type’s name.
parent: Option<TypeId>The parent struct type, if any.
fields: Vec<Field>All fields, the parent’s first.
methods: Vec<Method>Methods declared by this type (not the parent’s).
Trait Implementations§
impl Eq for StructDef
Source§impl Ord for StructDef
impl Ord for StructDef
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for StructDef
impl PartialOrd for StructDef
impl StructuralPartialEq for StructDef
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
Mutably borrows from an owned value. Read more