Sensitive content
step 1: i want to keep a mutable reference to an element of an RwLock so i don't have to keep writing it out every time
step 2: ah, i can't do that because the &mut would outlive the mutex guard. i'll create a block to scope the reference inside the mutex's lifetime
step 3: this works, but i need to call self.foo() which takes &mut self. this would mean having two mutable references to self simultanously, which isn't allowed
step 4: i'll create a closure to reduce the scope of the mutex ref. you'll have to use with_thingy(|thingy| thingy.whatever()), but it works
step 5: i can't do that because closures can't be cast to fn() pointers if they capture their environments, and i can't use impl Fn() because you can't use impl Trait in closure arguments.
now i've ended up with this abomination: a closure that takes a boxed closure that takes the mutable reference. i think i should have abandoned this approach somewhere around step 4
#rust






