File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -148,9 +148,9 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> NlaBuffer<T> {
148148    } 
149149} 
150150
151- impl < T :  AsRef < [ u8 ] >  + ?Sized >  NlaBuffer < & T >  { 
151+ impl < ' buf :   ' val ,   ' val ,   T :  AsRef < [ u8 ] >  + ?Sized >  NlaBuffer < & ' buf   T >  { 
152152    /// Return the `value` field 
153-      pub  fn  value ( & self )  -> & [ u8 ]  { 
153+      pub  fn  value ( & self )  -> & ' val   [ u8 ]  { 
154154        & self . buffer . as_ref ( ) [ VALUE ( self . value_length ( ) ) ] 
155155    } 
156156} 
@@ -374,4 +374,14 @@ mod tests {
374374    fn  test_align_overflow ( )  { 
375375        assert_eq ! ( nla_align!( get_len( )  - 3 ) ,  usize :: MAX ) ; 
376376    } 
377+ 
378+     // compile-time test, should not result in compiler complaints regarding 
379+     // lifetimes or returning values allegedly owned by the this function 
380+     #[ allow( dead_code) ]  
381+     fn  nla_buffer_outlives_value ( nlas :  & [ u8 ] )  -> Option < & [ u8 ] >  { 
382+         for  nla in  NlasIterator :: new ( nlas)  { 
383+             return  Some ( nla. unwrap ( ) . value ( ) ) 
384+         } 
385+         None 
386+     } 
377387} 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments