File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff 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
160166impl < ' 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 < _ > > ( ) ;
You can’t perform that action at this time.
0 commit comments