summaryrefslogtreecommitdiff
path: root/receme/src/functor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'receme/src/functor.rs')
-rw-r--r--receme/src/functor.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/receme/src/functor.rs b/receme/src/functor.rs
index 95e2555..cd4dac2 100644
--- a/receme/src/functor.rs
+++ b/receme/src/functor.rs
@@ -31,6 +31,14 @@ pub trait Functor<T> {
fn fmap<S>(self, f: impl FnMut(T) -> S) -> Self::Target<S>;
}
+impl<T> Functor<T> for Vec<T> {
+ type Target<S> = Vec<S>;
+
+ fn fmap<S>(self, f: impl FnMut(T) -> S) -> Self::Target<S> {
+ self.into_iter().map(f).collect()
+ }
+}
+
/// A functor can map over its generic type parameter.
///
/// It can map from Functor(T) to Functor(S).