pub struct ChainCall { /* private fields */ }Expand description
One dot-call in an AttributeChain.
Implementations§
Source§impl ChainCall
impl ChainCall
Sourcepub fn method(&self) -> &Ident
pub fn method(&self) -> &Ident
Examples found in repository?
examples/derive_field_attrs.rs (line 71)
55fn expand_field_attrs(field: &Field) -> syn::Result<Vec<TokenStream>> {
56 let field_ident = field
57 .ident
58 .as_ref()
59 .expect("named_fields only returns named struct fields");
60 let mut expansions = Vec::new();
61
62 for attr in &field.attrs {
63 if !attr.path().is_ident("attribute_dsl") {
64 continue;
65 }
66
67 let chain = attr.parse_args::<AttributeChain>()?;
68 let root = substitute_infer_in_path(chain.root_path(), &field.ty);
69
70 let calls = chain.calls().iter().map(|call| {
71 let method = call.method();
72 let turbofish = call.turbofish();
73 let args = call.args();
74 quote! { .#method #turbofish (#(#args),*) }
75 });
76
77 let completion = chain
78 .completion_marker()
79 .map(|marker| quote! { .#marker })
80 .unwrap_or_default();
81
82 expansions.push(quote! {
83 let _ = #root::builder_for(stringify!(#field_ident)) #(#calls)* #completion;
84 });
85 }
86
87 Ok(expansions)
88}Sourcepub fn turbofish(&self) -> Option<&AngleBracketedGenericArguments>
pub fn turbofish(&self) -> Option<&AngleBracketedGenericArguments>
Examples found in repository?
examples/derive_field_attrs.rs (line 72)
55fn expand_field_attrs(field: &Field) -> syn::Result<Vec<TokenStream>> {
56 let field_ident = field
57 .ident
58 .as_ref()
59 .expect("named_fields only returns named struct fields");
60 let mut expansions = Vec::new();
61
62 for attr in &field.attrs {
63 if !attr.path().is_ident("attribute_dsl") {
64 continue;
65 }
66
67 let chain = attr.parse_args::<AttributeChain>()?;
68 let root = substitute_infer_in_path(chain.root_path(), &field.ty);
69
70 let calls = chain.calls().iter().map(|call| {
71 let method = call.method();
72 let turbofish = call.turbofish();
73 let args = call.args();
74 quote! { .#method #turbofish (#(#args),*) }
75 });
76
77 let completion = chain
78 .completion_marker()
79 .map(|marker| quote! { .#marker })
80 .unwrap_or_default();
81
82 expansions.push(quote! {
83 let _ = #root::builder_for(stringify!(#field_ident)) #(#calls)* #completion;
84 });
85 }
86
87 Ok(expansions)
88}Sourcepub fn args(&self) -> &[Expr]
pub fn args(&self) -> &[Expr]
Examples found in repository?
examples/derive_field_attrs.rs (line 73)
55fn expand_field_attrs(field: &Field) -> syn::Result<Vec<TokenStream>> {
56 let field_ident = field
57 .ident
58 .as_ref()
59 .expect("named_fields only returns named struct fields");
60 let mut expansions = Vec::new();
61
62 for attr in &field.attrs {
63 if !attr.path().is_ident("attribute_dsl") {
64 continue;
65 }
66
67 let chain = attr.parse_args::<AttributeChain>()?;
68 let root = substitute_infer_in_path(chain.root_path(), &field.ty);
69
70 let calls = chain.calls().iter().map(|call| {
71 let method = call.method();
72 let turbofish = call.turbofish();
73 let args = call.args();
74 quote! { .#method #turbofish (#(#args),*) }
75 });
76
77 let completion = chain
78 .completion_marker()
79 .map(|marker| quote! { .#marker })
80 .unwrap_or_default();
81
82 expansions.push(quote! {
83 let _ = #root::builder_for(stringify!(#field_ident)) #(#calls)* #completion;
84 });
85 }
86
87 Ok(expansions)
88}Trait Implementations§
Source§impl ToTokens for ChainCall
impl ToTokens for ChainCall
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl !Send for ChainCall
impl !Sync for ChainCall
impl Freeze for ChainCall
impl RefUnwindSafe for ChainCall
impl Unpin for ChainCall
impl UnsafeUnpin for ChainCall
impl UnwindSafe for ChainCall
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Returns a
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.