-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
In libcore, convert functions to methods whereever it makes sense #6045
Comments
Some more information. Say there is a fn plus_one(x: int) -> int {
x + 1
} You would first convert this to a method by pasting it into an impl and changing the name of the first argument: impl int {
fn plus_one(self) -> int {
self + 1
}
} And then back in the original location redefine the function to do nothing except call the method:
Once all the functions are simply methods underneath, we can convert all the uses of functions in the compiler into methods, and then remove the functions entirely. But those latter two things are beyond the scope of this bug, just focus on creating the methods for now. |
I'm chugging away at this. |
This is currently blocked on #6068 |
This is nitpicking, but to me |
Example, @lucian1900? I do not understand. |
Oh, |
It makes sense to me for types without a literal, like |
Sure, but not the builtins. |
Visiting for triage; nothing to add |
Closing this, as most of the egregious modules ( |
…lip1995 Remove an extra blank line in `shadow_same` It seems to be an extra blank line in doc example. changelog: none <img width="1143" alt="スクリーンショット 2020-09-15 8 50 30" src="https://user-images.githubusercontent.com/17407489/93149409-369df080-f731-11ea-9a39-d8bbc72b61ee.png">
By "makes sense" I mostly mean "whereever the first argument to a function is the same type as the name of the module." So a function like
str::to_chars("asdf")
becomes"asdf".to_chars()
, butvec::from_fn(5, |x| x)
can be left as a function.The text was updated successfully, but these errors were encountered: