mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 17:10:34 +00:00
Add a new Binding::is_unused
method (#12729)
This commit is contained in:
parent
b14fee9320
commit
d380b37a09
9 changed files with 19 additions and 9 deletions
|
@ -36,9 +36,18 @@ pub struct Binding<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Binding<'a> {
|
||||
/// Return `true` if this [`Binding`] is unused.
|
||||
///
|
||||
/// This method is the opposite of [`Binding::is_used`].
|
||||
pub fn is_unused(&self) -> bool {
|
||||
self.references.is_empty()
|
||||
}
|
||||
|
||||
/// Return `true` if this [`Binding`] is used.
|
||||
///
|
||||
/// This method is the opposite of [`Binding::is_unused`].
|
||||
pub fn is_used(&self) -> bool {
|
||||
!self.references.is_empty()
|
||||
!self.is_unused()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all references for the current [`Binding`].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue