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> {
148
148
}
149
149
}
150
150
151
- impl < T : AsRef < [ u8 ] > + ?Sized > NlaBuffer < & T > {
151
+ impl < ' buf : ' val , ' val , T : AsRef < [ u8 ] > + ?Sized > NlaBuffer < & ' buf T > {
152
152
/// Return the `value` field
153
- pub fn value ( & self ) -> & [ u8 ] {
153
+ pub fn value ( & self ) -> & ' val [ u8 ] {
154
154
& self . buffer . as_ref ( ) [ VALUE ( self . value_length ( ) ) ]
155
155
}
156
156
}
@@ -374,4 +374,14 @@ mod tests {
374
374
fn test_align_overflow ( ) {
375
375
assert_eq ! ( nla_align!( get_len( ) - 3 ) , usize :: MAX ) ;
376
376
}
377
+
378
+ // compile-time test, should not result in compiler complaints regarding
379
+ // lifetimes or returning values allegedly owned by 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
+ }
377
387
}
You can’t perform that action at this time.
0 commit comments