MCPcopy Create free account
hub / github.com/apache/fory / self_construction

Function self_construction

rust/fory-derive/src/util.rs:52–58  ·  view source on GitHub ↗

Generate Self construction syntax. - tuple struct: `Self(field0, field1, ...)` - named struct: `Self { field0, field1, ... }`

(is_tuple_struct: bool, field_inits: &[TokenStream])

Source from the content-addressed store, hash-verified

50/// - tuple struct: `Self(field0, field1, ...)`
51/// - named struct: `Self { field0, field1, ... }`
52pub fn self_construction(is_tuple_struct: bool, field_inits: &[TokenStream]) -> TokenStream {
53 if is_tuple_struct {
54 quote! { Self( #(#field_inits),* ) }
55 } else {
56 quote! { Self { #(#field_inits),* } }
57 }
58}
59
60/// Generate Ok(Self(...)) construction syntax for Result return.
61pub fn ok_self_construction(is_tuple_struct: bool, field_inits: &[TokenStream]) -> TokenStream {

Callers 1

generate_default_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected