Annotate builder functions with #[must_use] (#2841)

This commit is contained in:
Jesse Braham 2024-12-19 02:10:23 -08:00 committed by GitHub
parent cde6169d6d
commit 036d08e09f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -463,6 +463,7 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
fns.push(quote! {
#[doc = concat!(" Assign the given value to the `", stringify!(#field_ident) ,"` field.")]
#[must_use]
pub fn #function_ident(mut self, #field_ident: #field_type) -> Self {
self.#field_ident = #field_assigns;
self
@ -473,6 +474,7 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
let function_ident = format_ident!("with_{}_none", field_ident);
fns.push(quote! {
#[doc = concat!(" Set the value of `", stringify!(#field_ident), "` to `None`.")]
#[must_use]
pub fn #function_ident(mut self) -> Self {
self.#field_ident = None;
self