pub struct VariantBuilder { /* private fields */ }Expand description
Builder for constructing Variant instances in const contexts.
This builder enables shorter derive macro output by providing a fluent API for constructing variants with default values for optional fields.
§Example
use facet_core::{VariantBuilder, StructTypeBuilder, StructKind, Variant};
const VARIANT: Variant = VariantBuilder::new(
"Foo",
StructTypeBuilder::new(StructKind::Unit, &[]).build()
)
.discriminant(42)
.build();Implementations§
Source§impl VariantBuilder
impl VariantBuilder
Sourcepub const fn new(name: &'static str, data: StructType) -> Self
pub const fn new(name: &'static str, data: StructType) -> Self
Creates a new VariantBuilder with the required fields.
§Parameters
name: The name of the variantdata: The struct type representing the variant’s fields
Sourcepub const fn discriminant(self, discriminant: i64) -> Self
pub const fn discriminant(self, discriminant: i64) -> Self
Sets the discriminant value for this variant.
Defaults to None if not called.
Sourcepub const fn attributes(self, attributes: &'static [VariantAttribute]) -> Self
pub const fn attributes(self, attributes: &'static [VariantAttribute]) -> Self
Sets the attributes for this variant.
Defaults to an empty slice if not called.
Trait Implementations§
Source§impl Clone for VariantBuilder
impl Clone for VariantBuilder
Source§fn clone(&self) -> VariantBuilder
fn clone(&self) -> VariantBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VariantBuilder
impl Debug for VariantBuilder
impl Copy for VariantBuilder
Auto Trait Implementations§
impl Freeze for VariantBuilder
impl RefUnwindSafe for VariantBuilder
impl Send for VariantBuilder
impl Sync for VariantBuilder
impl Unpin for VariantBuilder
impl UnwindSafe for VariantBuilder
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