mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
FIX lint clippy::len_without_is_empty (#451)
This commit is contained in:
parent
418bd89ba4
commit
4161bad54f
@ -41,6 +41,11 @@ impl Array {
|
|||||||
Self(vec)
|
Self(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return `true` if the length is 0.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.0.len() == 0
|
||||||
|
}
|
||||||
|
|
||||||
/// The length of the array.
|
/// The length of the array.
|
||||||
pub fn len(&self) -> i64 {
|
pub fn len(&self) -> i64 {
|
||||||
self.0.len() as i64
|
self.0.len() as i64
|
||||||
|
@ -34,6 +34,11 @@ impl Str {
|
|||||||
Self(EcoString::new())
|
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.
|
/// The length of the string in bytes.
|
||||||
pub fn len(&self) -> i64 {
|
pub fn len(&self) -> i64 {
|
||||||
self.0.len() as i64
|
self.0.len() as i64
|
||||||
|
@ -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.
|
/// The byte length of the node in the source text.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
|
@ -1324,7 +1324,7 @@ impl<'s> Parser<'s> {
|
|||||||
while self
|
while self
|
||||||
.nodes
|
.nodes
|
||||||
.last()
|
.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();
|
self.nodes.pop();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user