top | item 33726007 (no title) 0b01 | 3 years ago 4. Cast to &'static and *. Expert Rust hacker level. discuss order hn newest willglynn|3 years ago `Box::leak()` gets you a `&'static` at runtime. No raw pointers and no `unsafe`, but also no way to free the memory (because `&'static`).This is a technique I've used in anger: https://github.com/AS207960/xml-serde/pull/8 ibotty|3 years ago I didn't read the pull request in detail, but won't leaking the fields lead to memory leaks when `xml-serde` is used in a long-running application? load replies (1)
willglynn|3 years ago `Box::leak()` gets you a `&'static` at runtime. No raw pointers and no `unsafe`, but also no way to free the memory (because `&'static`).This is a technique I've used in anger: https://github.com/AS207960/xml-serde/pull/8 ibotty|3 years ago I didn't read the pull request in detail, but won't leaking the fields lead to memory leaks when `xml-serde` is used in a long-running application? load replies (1)
ibotty|3 years ago I didn't read the pull request in detail, but won't leaking the fields lead to memory leaks when `xml-serde` is used in a long-running application? load replies (1)
willglynn|3 years ago
This is a technique I've used in anger: https://github.com/AS207960/xml-serde/pull/8
ibotty|3 years ago