Commit 9cd7ce7
committed
Explicitly bind lifetimes for NlaBuffer.value()
Without this, the following results in an error:
```
fn subnlas_by_kind<'a>(nlas: &'a [u8]) -> HashMap<u16, Vec<&'a [u8]>> {
let mut out = HashMap::new();
for n in NlasIterator::new(nlas) {
let n = n.unwrap();
let entry: &mut Vec<_> = out.entry(n.kind()).or_default();
(*entry).push(n.value())
}
Ok(out)
}
```
```
error[E0515]: cannot return value referencing local variable `n`
|
212 | (*entry).push(n.value())
| - `n` is borrowed here
213 | }
214 | Ok(out)
| ^^^^^^^ returns a value referencing data owned by the current function
```1 parent b40f3d6 commit 9cd7ce7
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
0 commit comments