Skip to content

Commit 32d4ab0

Browse files
committed
clippy wants is_empty to exist as well
1 parent a7f76cf commit 32d4ab0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rust/ruby-prism/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ impl<'pr> NodeList<'pr> {
155155
pub const fn len(&self) -> usize {
156156
unsafe { self.pointer.as_ref().size }
157157
}
158+
159+
/// Returns whether the list is empty.
160+
#[must_use]
161+
pub const fn is_empty(&self) -> bool {
162+
self.len() == 0
163+
}
158164
}
159165

160166
impl<'pr> IntoIterator for &NodeList<'pr> {
@@ -802,6 +808,7 @@ mod tests {
802808

803809
let node = result.node();
804810
assert_eq!(node.as_program_node().unwrap().statements().body().len(), 1);
811+
assert!(!node.as_program_node().unwrap().statements().body().is_empty());
805812
let module = node.as_program_node().unwrap().statements().body().iter().next().unwrap();
806813
let module = module.as_module_node().unwrap();
807814
let locals = module.locals().iter().collect::<Vec<_>>();

0 commit comments

Comments
 (0)