Lenses in Rust and My Solution

21 points by LambdaLemon


polywolf

This is a fairly nice API, especially compared to the examples you show, but the part I'm still confused about is how a self: &Optics<'_, Foo> allows for mutation of self.y. It is behind a shared reference, so any mutation seems about as safe as mutation of a RefCell. That is, it needs to be checked by hand & at runtime instead of being enforced by the type system.

Looking at your code, this is indeed the case: there are panic!("gulp") cases to handle invalid borrows. Do you know if the other lens crates have this same failure mode?

aspizu

wow ur the coolest ur so good at rust lemon this is so crazy no way im literally crying