Skip to content

Is it possible to parameterize traits over self mode? #7918

Closed
@bblum

Description

@bblum

I have no idea if this is theoretically easy or impossible or what. But consider this trait from my design for select:

trait SelectPort<T> {
    fn recv_ready(self) -> Option<T>;
}

This takes self by value because for a oneshot port, it has to consume the endpoint. But for a stream port, you might not be allowed to have it by value at all, but still expect to be able to select on it. It would be nice to have:

trait SelectPort<T, selfmode> {
    fn recv_ready(selfmode) -> Option<T>;
}

and then:

impl <T> SelectPort<T, self> for PortOne<T> ...
impl <T> SelectPort<T, &mut self> for Port<T> ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions