#[non_exhaustive]#[repr(C)]pub struct Shape {
pub id: ConstTypeId,
pub layout: Layout,
pub vtable: &'static ValueVTable,
pub def: Def,
pub type_params: &'static [TypeParam],
pub doc: &'static [&'static str],
}Expand description
Schema for reflection of a type
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: ConstTypeIdUnique type identifier, provided by the compiler.
layout: LayoutSize, alignment — enough to allocate a value of this type (but not initialize it.)
vtable: &'static ValueVTableFunction pointers to perform various operations: print the full type name (with generic type parameters), use the Display implementation, the Debug implementation, build a default value, clone, etc.
There are more specific vtables in variants of Def
def: DefFurther definition of the value: details for structs, enums, scalars, options, smart pointers, arrays, slices, tuples, etc.
This typically lists fields (with shapes and offsets), reprs, variants and contains vtables that let you perform other operations, like inserting into a map or fetching a value from a list.
type_params: &'static [TypeParam]Generic parameters for the shape
doc: &'static [&'static str]Doc comment lines, collected by facet-derive. Note that they tend to start with a space.
Implementations§
Source§impl Shape
impl Shape
Sourcepub const fn is(&'static self, characteristic: Characteristic) -> bool
pub const fn is(&'static self, characteristic: Characteristic) -> bool
Checks if a shape has the given characteristic.
Sourcepub const fn is_display(&'static self) -> bool
pub const fn is_display(&'static self) -> bool
Check if this shape implements the Display trait
Sourcepub const fn is_partial_eq(&'static self) -> bool
pub const fn is_partial_eq(&'static self) -> bool
Check if this shape implements the PartialEq trait
Sourcepub const fn is_partial_ord(&'static self) -> bool
pub const fn is_partial_ord(&'static self) -> bool
Check if this shape implements the PartialOrd trait
Sourcepub const fn is_default(&'static self) -> bool
pub const fn is_default(&'static self) -> bool
Check if this shape implements the Default trait
Sourcepub const fn is_from_str(&'static self) -> bool
pub const fn is_from_str(&'static self) -> bool
Check if this shape implements the FromStr trait
Sourcepub fn write_type_name(
&self,
f: &mut Formatter<'_>,
opts: TypeNameOpts,
) -> Result<(), Error>
pub fn write_type_name( &self, f: &mut Formatter<'_>, opts: TypeNameOpts, ) -> Result<(), Error>
Writes the name of this type to the given formatter
Source§impl Shape
impl Shape
Sourcepub const fn builder() -> ShapeBuilder
pub const fn builder() -> ShapeBuilder
Returns a builder for shape
Sourcepub fn is_type<Other>(&'static self) -> boolwhere
Other: Facet,
pub fn is_type<Other>(&'static self) -> boolwhere
Other: Facet,
Check if this shape is of the given type
Sourcepub fn assert_type<Other>(&'static self)where
Other: Facet,
pub fn assert_type<Other>(&'static self)where
Other: Facet,
Assert that this shape is of the given type, panicking if it’s not