#Blanket implementing a trait for any type that implments Fn

6 messages · Page 1 of 1 (latest)

outer notch
#

if both T0: SomeTrait and (): Tuple, then which of the impls should the compiler use? ```rs
impl<F: Fn<Args>, Args: Tuple> Function for F {}
impl<F: Fn() -> T0, T0> Function for F where T0: SomeTrait {}

#

in general the feature is called specialization and in its full form it's unfinished

#

there are simple cases where it works (min_specialization), but I don't think this is exactly one of them

#

specifically, the current feature doesn't work when 2 impls are both bounded by different unrelated traits

#

yeah, say you have a hypothetical type Foo that implements Fn() and Fn(i32) and both (): Tuple and (i32,): Tuple, then Foo will implement Function in 2 different ways

#

which is not allowed