diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs index 7a75fc31..e97ff3ab 100644 --- a/futures/src/subscription.rs +++ b/futures/src/subscription.rs @@ -76,10 +76,6 @@ where /// /// The value will be part of the identity of a [`Subscription`]. /// - /// This is necessary if you want to use multiple instances of the same - /// [`Subscription`] to produce different kinds of messages based on some - /// external data. - /// /// [`Subscription`]: struct.Subscription.html pub fn with(mut self, value: T) -> Subscription where @@ -103,24 +99,19 @@ where /// Transforms the [`Subscription`] output with the given function. /// /// [`Subscription`]: struct.Subscription.html - pub fn map( - mut self, - f: impl Fn(O) -> A + Send + Sync + 'static, - ) -> Subscription + pub fn map(mut self, f: fn(O) -> A) -> Subscription where H: 'static, E: 'static, O: 'static, A: 'static, { - let function = std::sync::Arc::new(f); - Subscription { recipes: self .recipes .drain(..) .map(|recipe| { - Box::new(Map::new(recipe, function.clone())) + Box::new(Map::new(recipe, f)) as Box> }) .collect(), @@ -186,13 +177,13 @@ pub trait Recipe { struct Map { recipe: Box>, - mapper: std::sync::Arc B + Send + Sync>, + mapper: fn(A) -> B, } impl Map { fn new( recipe: Box>, - mapper: std::sync::Arc B + Send + Sync + 'static>, + mapper: fn(A) -> B, ) -> Self { Map { recipe, mapper } } @@ -209,8 +200,8 @@ where fn hash(&self, state: &mut H) { use std::hash::Hash; - std::any::TypeId::of::().hash(state); self.recipe.hash(state); + self.mapper.hash(state); } fn stream(self: Box, input: BoxStream) -> BoxStream {