Skip to content

Commit

Permalink
Relax lifetime constraints on mapped_ref and mapped_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
benschulz authored and rustonaut committed Mar 22, 2024
1 parent 454b364 commit 185767d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ impl<T> Vec1<T> {
///
/// The benefit to this compared to `Iterator::map` is that it's known
/// that the length will still be at least 1 when creating the new `Vec1`.
pub fn mapped_ref<F, N>(&self, map_fn: F) -> Vec1<N>
pub fn mapped_ref<'a, F, N>(&'a self, map_fn: F) -> Vec1<N>
where
F: FnMut(&T) -> N,
F: FnMut(&'a T) -> N,
{
Vec1(self.iter().map(map_fn).collect::<Vec<_>>())
}
Expand All @@ -290,9 +290,9 @@ impl<T> Vec1<T> {
///
/// The benefit to this compared to `Iterator::map` is that it's known
/// that the length will still be at least 1 when creating the new `Vec1`.
pub fn mapped_mut<F, N>(&mut self, map_fn: F) -> Vec1<N>
pub fn mapped_mut<'a, F, N>(&'a mut self, map_fn: F) -> Vec1<N>
where
F: FnMut(&mut T) -> N,
F: FnMut(&'a mut T) -> N,
{
Vec1(self.iter_mut().map(map_fn).collect::<Vec<_>>())
}
Expand Down

0 comments on commit 185767d

Please sign in to comment.