Revert "RFC to require impl MyStruct to be nearby the definition of MyStruct"#735
Revert "RFC to require impl MyStruct to be nearby the definition of MyStruct"#735brson merged 1 commit intorust-lang:masterfrom
impl MyStruct to be nearby the definition of MyStruct"#735Conversation
|
See also this comment about some of the consequences of UFCS. |
|
Sounds good! |
|
I agree with the sentiment, however there remains some amount of impl work to be done before the arguments in the original RFC no longer apply, no? |
|
Yes, hopefully I'll get to it in the next couple of weeks (I already figured out the details). |
|
Does this mean that it will be possible to write something like pub struct SomeType { ... }
mod some_functionality {
use super::SomeType;
impl SomeType {
fn do_something(&self) { ... }
}
fn free_func() {
let s: SomeType = ...;
s.do_something();
}
}or maybe even pub struct SomeType { ... }
mod some_functionality {
use super::SomeType;
impl SomeType {
fn do_something(&self) { ... }
}
}
fn free_func() {
let s: SomeType = ...;
s.do_something();
}? If so, it is great! It will help structuring programs immensely. |
|
@netvl Both work before UFCS if you remove the restriction. I had a PR doing this a while back, it required amending the RFC and I never got back to it. |
|
👍 but instead of deleting the original RFC, @eddyb can we have a new RFC that reverses the design? It can be pretty short. I'd prefer to leave the RFC for historical purposes. |
|
@brson I guess it could be something small explaining how UFCS allows resolution to ignore |
|
Merged. |
The "Revised UFCS proposal", PR #132, makes the restriction imposed by PR #155 unnecessary:
This applies to all non-trait
impls, and because<T>::itemhas to be handled during type-checking, that removes any need to handleimpls (or treat them as modules, for that matter) in resolution, eliminatingall the issues #155 was trying to solve by being overly conservative.