FIX lint clippy::len_without_is_empty (#451)

This commit is contained in:
Marek Barvíř 2023-03-31 17:13:31 +02:00 committed by GitHub
parent 418bd89ba4
commit 4161bad54f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -41,6 +41,11 @@ impl Array {
Self(vec)
}
/// Return `true` if the length is 0.
pub fn is_empty(&self) -> bool {
self.0.len() == 0
}
/// The length of the array.
pub fn len(&self) -> i64 {
self.0.len() as i64

View File

@ -34,6 +34,11 @@ impl Str {
Self(EcoString::new())
}
/// Return `true` if the length is 0.
pub fn is_empty(&self) -> bool {
self.0.len() == 0
}
/// The length of the string in bytes.
pub fn len(&self) -> i64 {
self.0.len() as i64

View File

@ -53,6 +53,11 @@ impl SyntaxNode {
}
}
/// Return `true` if the length is 0.
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// The byte length of the node in the source text.
pub fn len(&self) -> usize {
match &self.0 {

View File

@ -1324,7 +1324,7 @@ impl<'s> Parser<'s> {
while self
.nodes
.last()
.map_or(false, |child| child.kind() == SyntaxKind::Error && child.len() == 0)
.map_or(false, |child| child.kind() == SyntaxKind::Error && child.is_empty())
{
self.nodes.pop();
}