We could allow bounds to be locally inferred. E.g., `impl<X> T<X> for S<X>
{ ... }` would infer the lub of bounds from T and S for X. But since we can
have an impl for any type, not just a struct, I think the general case
might be too tricky to do inference for. We might also want to take into
account uses of X in the body of the impl, and then things get really
tricky. We don't infer bounds anywhere else in Rust, so I'm not sure if we
would want to do this in any case.

So, I think the best course of action would be to require the bounds, and
then see how much unnecessary code duplication there is. If there is a lot,
look at doing inference.

Cheers, Nick.


On Wed, Mar 26, 2014 at 7:00 PM, comex <[email protected]> wrote:

> On Tue, Mar 25, 2014 at 8:29 PM, Nick Cameron <[email protected]> wrote:
> > I made an RFC - https://github.com/rust-lang/rfcs/pull/20
>
> In my half-baked opinion, it's nice to put bounds on a struct rather
> than its impl(s), so that nonsensical specializations cannot be
> created, rather than being creatable but having no methods due to
> failing the impl bound.  But it's ugly to have to write the bounds
> twice.  Is there a reasonable way to have the bounds be implied on the
> impl?
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to