Oh thanks, I see.
Maybe I’m looking then for some not-yet-existent functionality like:
struct Precious;
// Instead of dropping the fields of X on Drop each on their
// own, the compiler will pass them to a custom function
// where they can be used together for some clean-up.
#[do_with_fields_after_drop("X::after_drop", "precious", "sender")]
struct X {
precious: Precious,
sender: Sender<Precious>,
not_so_important: u64,
}
impl X {
// Just an example what I could do with those fields:
fn after_drop(precious: Precious, sender: Sender<Precious>) {
// Good: I can consume precious and sender, therefore I can call
// Sender::send(self, T)
sender.send(precious).unwrap()
}
fn do_something(&self) {
// Good: I can use self.precious without any match or Option::unwrap
self.precious.foo();
}