atomic_refcell icon indicating copy to clipboard operation
atomic_refcell copied to clipboard

Improve mapping features

Open gzp79 opened this issue 2 years ago • 1 comments

There's an already open request about an owned_map feature that return a non-borrowed object. Please consider improving the API with other construct as well:

  • map : &T -> &(mut) U
  • filter_map : &T -> Option<&(mut) U>
  • try_map : &T -> Result<&(mut) U, E>
  • and their "owning" version as described in #11

I felt like this is a bit broader request as the #11, thus I've created a new issue.

gzp79 avatar Feb 04 '23 08:02 gzp79

I'd absolutely love this.

What I think would be great is a &mut (T, U) -> (&mut T, &mut U) because it is quite common to have a single refcell to lock multiple pieces of data, but you'd need to return them as disjoint references. Two atomic refcells does partly solve the issue, but required double borrowing each time

ten3roberts avatar Jul 06 '23 21:07 ten3roberts

While this feature were great, but as there was no updated on the topic for a year, I'm closing the issue.

gzp79 avatar Jul 18 '24 14:07 gzp79