You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to make a blanket impl MyTrait for T: FunctorMut<'a, A>? #1
I tried to implement another trait (Sanitize) for all FunctorMut's where the item implements Sanitize. But when I try to do this:
use fmap::FunctorMut;/// The Sanitize trait generalises types that are to be sanitized.pubtraitSanitize{/// Call this associated method when sanitizing.fnsanitize(&mutself);}/// A blanket impl that allows sanitizing values inside of common data structures like [Option] and [Vec].////// ## Example////// ```/// use sanitizer::Sanitize;////// #[derive(Debug, PartialEq)]/// struct MyValue(i32);////// impl Sanitize for MyValue {/// /// If the inner value is `0`, change it to `1`./// fn sanitize(&mut self) {/// if self.0 == 0 {/// self.0 = 1;/// }/// }/// }////// let mut wrapped_value = Some(MyValue(0));/// wrapped_value.sanitize();/// assert_eq!(wrapped_value, Some(MyValue(1)));/// ```impl<'a,A,T>SanitizeforTwhereA:'a,T:FunctorMut<'a,A>,T::Inner:Sanitize,{fnsanitize(&mutself){self.fmap_mut(Sanitize::sanitize)}}
I get this error:
error[E0207]: the type parameter `A` is not constrained by the impl trait, self type, or predicates
Activity