@@ -375,15 +375,6 @@ mod tests {
375
375
assert_eq ! ( nla_align!( get_len( ) - 3 ) , usize :: MAX ) ;
376
376
}
377
377
378
- // compile-time test: it should be possible to pass &[u8] through
379
- // NlasIterator and return one of its output &[u8]s without facing
380
- // compiler error about lifetimes and returning borrows from something
381
- // that this funciton owns
382
- fn last_nla_from_buffer ( nlas : & [ u8 ] ) -> Option < Result < & [ u8 ] , DecodeError > > {
383
- NlasIterator :: new ( nlas) . last ( )
384
- . map ( |nla| nla. map ( |nla| nla. value ( ) ) )
385
- }
386
-
387
378
#[ test]
388
379
fn test_nlas_iterator ( ) {
389
380
// sample NFTA_LIST_ELEM from nftables, with nested nlas at the end
@@ -404,6 +395,16 @@ mod tests {
404
395
405
396
// this sholud be an Err()
406
397
let truncated = & NESTED_NLAS [ .. NESTED_NLAS . len ( ) -1 ] ;
407
- assert ! ( last_nla_from_buffer( truncated) . unwrap( ) . is_err( ) ) ;
398
+ assert ! ( NlasIterator :: new( truncated) . last( ) . unwrap( ) . is_err( ) ) ;
399
+
400
+ let last = {
401
+ // it should be possible to pass &[u8] through
402
+ // NlasIterator and return one of its output &[u8]s without facing
403
+ // compiler error about lifetimes and returning borrows from
404
+ // something is limited to this scope
405
+ let last = NlasIterator :: new ( NESTED_NLAS ) . last ( ) ;
406
+ last. unwrap ( ) . unwrap ( ) . value ( )
407
+ } ;
408
+ assert_eq ! ( last, & NESTED_NLAS [ 16 ..] ) ;
408
409
}
409
410
}
0 commit comments