Stream: wg-traits

Topic: paired associated type & method specialization


Jake Goulding (Apr 01 2019 at 16:13, on Zulip):

This code fails:

#![feature(specialization)]

#[derive(Debug)]
struct Wrapper<T>(T);

trait ToWrapper {
    type Inner;

    fn to_wrap(self) -> Wrapper<Self::Inner>;
}

default impl<T> ToWrapper for T {
    type Inner = T;

    fn to_wrap(self) -> Wrapper<Self::Inner> {
        Wrapper(self)
    }
}

From this Q&A, it's stated that's because we might specialize either Inner or to_wrap separately from the other, which means that the default implementation might be broken.

Jake Goulding (Apr 01 2019 at 16:14, on Zulip):

That much makes sense to me, but is there a way of stating that an associated type and method must be specialized together?

centril (Apr 01 2019 at 16:16, on Zulip):

@Jake Goulding see discussion in https://github.com/rust-lang/rfcs/pull/2532

Jake Goulding (Apr 01 2019 at 16:18, on Zulip):

A Graydon approval, nice

Jake Goulding (Apr 01 2019 at 16:19, on Zulip):

@centril the only relevant comment I see that mentions specialization is this one

centril (Apr 01 2019 at 16:20, on Zulip):

@Jake Goulding and read the RFC :slight_smile:

centril (Apr 01 2019 at 16:20, on Zulip):

especially "future work"

Jake Goulding (Apr 01 2019 at 16:20, on Zulip):

GitHub Pages is temporarily down for maintenance.

sigh

Jake Goulding (Apr 01 2019 at 16:22, on Zulip):

So the answer is "no"

Jake Goulding (Apr 01 2019 at 16:24, on Zulip):

Any feelings on when the future work might be considered again?

centril (Apr 01 2019 at 16:43, on Zulip):

@Jake Goulding I think the RFC should be stabilized first before we reconsider

Last update: Nov 12 2019 at 16:00UTC