Closed as not planned
Description
- All associated functions must either be dispatchable from a trait object or be explicitly non-dispatchable:
- Dispatchable functions must:
- [...]
- Not have a
where Self: Sized
bound (receiver type ofSelf
(i.e.self
) implies this).- Explicitly non-dispatchable functions require:
- Have a
where Self: Sized
bound (receiver type ofSelf
(i.e.self
) implies this).
However, it is not true that a receiver type of Self
implies Self: Sized
.
// Minimal example; it also can be demonstrated with bounds that
// require `Sized`, like `<G: From<Self>>` say, even without a
// function body
trait Trait {
// Fails without an explicit `where Self: Sized` bound
fn method(self) {}
}
Accepting self
-receiving methods as object-safe methods was a separate consideration from a Self: Sized
bound in the RFC.
This is why all methods that require Self:Sized are exempt from the typical rules. This is also why by-value self methods are permitted, since currently one cannot invoke pass an unsized type by-value (though we consider that a useful future extension).
Metadata
Metadata
Assignees
Labels
No labels