Skip to content

Commit

Permalink
Add Array::map (#61)
Browse files Browse the repository at this point in the history
Alternative to #60

Co-authored-by: Tony Arcieri <bascule@gmail.com>
  • Loading branch information
baloo and tarcieri authored Mar 5, 2024
1 parent f3cbc52 commit 10e6dff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ where
self.as_mut().iter_mut()
}

/// Returns an array of the same size as `self`, with function `f` applied to each element in
/// order.
pub fn map<F, O>(self, f: F) -> Array<O, U>
where
F: FnMut(T) -> O,
{
self.into_iter().map(f).collect()
}

/// Concatenates `self` with `other`.
#[inline]
pub fn concat<N>(self, other: Array<T, N>) -> Array<T, Sum<U, N>>
Expand Down

0 comments on commit 10e6dff

Please sign in to comment.