The underscore binding is used for fields, which should not be used. In my project, I often use PhantomData to store a lifetime. This triggers the clippy::used_underscore_binding lint, when deriving TypedBuilder
Reproducer
#![warn(clippy::used_underscore_binding)]
use std::marker::PhantomData;
use typed_builder::TypedBuilder;
#[derive(TypedBuilder)]
pub struct Bar<'ast> {
#[builder(default)]
_lifetime: PhantomData<&'ast ()>,
}
And run cargo clippy
Suggestions
I'm not sure, if there is a simple way to fix this. Maybe #[allow(clippy::used_underscore_binding)] would fix it. Another option could be the addition of a new #[builder] attribute, that only sets the value and doesn't allow the user to override it.
These are just some suggestions, there are probably better solutions.
The underscore binding is used for fields, which should not be used. In my project, I often use
PhantomData
to store a lifetime. This triggers theclippy::used_underscore_binding
lint, when derivingTypedBuilder
Reproducer
And run
cargo clippy
Suggestions
I'm not sure, if there is a simple way to fix this. Maybe
#[allow(clippy::used_underscore_binding)]
would fix it. Another option could be the addition of a new#[builder]
attribute, that only sets the value and doesn't allow the user to override it.These are just some suggestions, there are probably better solutions.