Skip to content

Commit

Permalink
lib Merge: add Merge::map_owned method that consumes the map
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Oct 13, 2024
1 parent a943378 commit 8c6129f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ impl<T> Merge<T> {
self.values.iter_mut()
}

/// Creates a new merge by applying `f` to each remove and add.
pub fn map_owned<U>(self, f: impl FnMut(T) -> U) -> Merge<U> {
let values = self.values.into_iter().map(f).collect();
Merge { values }
}

/// Creates a new merge by applying `f` to each remove and add.
pub fn map<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> Merge<U> {
let values = self.values.iter().map(f).collect();
Expand Down

0 comments on commit 8c6129f

Please sign in to comment.