pub struct FieldsDecl { /* private fields */ }Expand description
A value-form expansion: the accessor whose returned struct supplies the
fields, plus the per-field adjustments. Built with
fields! and handed to
ExpandReturnDecl::fields.
Both adjusters key on the Rust struct field name, mirroring
FunctionDecl::expand_param’s Rust-parameter-name key: an unknown field
name or a repeated one is a hard error, so a field renamed upstream is
caught rather than silently ignored.
Implementations§
Source§impl FieldsDecl
impl FieldsDecl
pub fn new(func: Ident) -> Self
Sourcepub fn overrides(&self) -> &[(String, ExpandReturnDecl)]
pub fn overrides(&self) -> &[(String, ExpandReturnDecl)]
The per-field decomposition overrides, in declaration order.
Sourcepub fn is_consuming(&self) -> bool
pub fn is_consuming(&self) -> bool
Whether the accessor consumes its receiver (set by
ExpandReturnDecl::fields_self_into). Named is_consuming rather
than consuming — that name is already the crate-internal builder
method that sets the flag.
Sourcepub fn field(self, field: impl AsRef<str>, decl: ExpandReturnDecl) -> Self
pub fn field(self, field: impl AsRef<str>, decl: ExpandReturnDecl) -> Self
Replace one field’s decomposition, with the same
ExpandReturnDecl a type-level default uses — so the complete-set
rule applies here too: the decl states that field’s entire leaf set.
Use it where the field’s type default is not what this boundary wants
(a lone .field_self() keeps the raw handle instead of decomposing it).
An override declaring no records states an empty leaf set: the field
does not cross. That is the one way to drop a field a value form
carries, and it follows from the complete-set rule rather than adding a
rule — a boundary that wants none of a field’s leaves says so the same
way it says it wants some of them. (A generator-level
expand_return!(T) with no records is still an error: a type has to
cross somehow.) Use it for a field the binding has no surface for —
diagnostics a consumer never reads, a type whose accessors would drag in
a subtree nothing asks for:
prebindgen_registry::expand_return!(Sample).fields_self_into(
prebindgen_registry::fields!(sample_into_struct)
.field("timestamp_stack", prebindgen_registry::expand_return!(TimestampStack)),
);Trait Implementations§
Source§impl Clone for FieldsDecl
impl Clone for FieldsDecl
Source§fn clone(&self) -> FieldsDecl
fn clone(&self) -> FieldsDecl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Send for FieldsDecl
impl !Sync for FieldsDecl
impl Freeze for FieldsDecl
impl RefUnwindSafe for FieldsDecl
impl Unpin for FieldsDecl
impl UnsafeUnpin for FieldsDecl
impl UnwindSafe for FieldsDecl
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,
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