-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Static methods in traits #14582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a "feature" (well, a bug too, but it's well covered elsewhere, e.g. #6894). Static methods need to be called like trait MyTrait {
fn act(_dummy: Option<Self>);
}
fn act<T: MyTrait>(val: &T) {
MyTrait::act(None::<T>); // call T's act method
} This precise behaviour is covered by "uniform function call syntax", which is being discussed in RFCs like rust-lang/rfcs#4. (Thanks for filing.) |
Thanks for the answer! But my act actually returned Self, so i didn't even use this hack. |
Yes, it will be fixed; the RFC I linked above is proposing a fix, but there is still some discussion happening in this area. If you don't own |
Is this a bug or a feature?
Gives:
The text was updated successfully, but these errors were encountered: