Expand Lens / Lens derive functionality
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
#118 landed an absolute barebones version of Lens derive. There's also been some discussion in Zulip about a [Lens2](https://git.sr.ht/~raph/interp-toy/tree/master/src/lens2.rs) and whatever that might entail.
Also, as @cmyr mentioned in #118:
> As future work we're also going to want to support (at the very least) deriving lenses into collections; in this case the concrete type of the Lens will need a field for the index of the collection we want.
> This also makes lenses fallible (you might have an invalid index), which is something we'll want to to think about; we want to at least handle this without crashing.
One more also: I ended up dropping the `lens_wrap!` macro because it's unclear what the ideal usage should be.
Here's an alternative @cmyr mentioned in the PR:
```rust
impl Point {
fn lens_width(&self, inner: I) -> impl LensWrap, I> {
druid::LensWrap::new(inner, lenses::point::width)
}
}
let wrapped_widget = Point::lens_width(my_widget);
```
*What would help:* a concrete an example of a Lens on a collection, and any further ideas on LensWrap.
Contributor guide
Research direction
Read the existing Lens derive work from #118 and inspect src/lens2.rs for the proposed Lens2 direction. Define a concrete collection-lens example and resolve the intended LensWrap API; done requires an agreed design for collection indices, fallible access, and wrapping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100