More specifically, a confusing but ever-so-common construct is:
if (!self.doneonce) {
let x = get_substring(self.x);
println!("{} {} whatever", self.a, x);
}
and it's bad for many reasons:
- completely unclear variable names.
- the example I showed has a bug.
maybe you'll get warnings about unused struct fields or w/e but I'd much rather be able to just write:
self.logged.call_once(|| {
let x = get_substring(self.x);
println!("{} {} whatever", self.a, x);
});
and I can't do that with the standard Once. the standard Once is not standard enough - instead, it's too niche.
so, can we get nice Once? all it takes is to remove an 'static lifetime bounds.