3 ms·
fn maybe_alloc() -> Vec<usize> { if collatz_conjecture_is_true() { vec![42] } else { vec![] } } fn main
by umanwizard 5y ago
fn maybe_alloc() -> Vec<usize> {
if collatz_conjecture_is_true() {
vec![42]
} else {
vec![]
}
}
fn main() {
let v = maybe_alloc(); // Does this allocate?
}
- wtetzner 5y agoYou would just assume it does. Really you want to detect all places that might allocate.
- umanwizard 5y agoYou are right. It’s definitely possible if you accept false positives.