Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upuse some::Trait as _; #1311
Comments
This comment has been minimized.
This comment has been minimized.
|
yes yes yes! |
This comment has been minimized.
This comment has been minimized.
wthrowe
commented
Oct 16, 2015
|
If these can be public and glob imports match them they would be nice for preludes. I imagine they would have been used for |
This comment has been minimized.
This comment has been minimized.
|
@wthrowe good point, I like that suggestion. |
nrc
added
the
T-lang
label
Aug 22, 2016
This comment has been minimized.
This comment has been minimized.
|
+1, this would be nice to have. |
This comment has been minimized.
This comment has been minimized.
jseyfried
commented
Aug 22, 2016
|
Also +1, I like this idea. One potential downside is extra complexity for |
This comment has been minimized.
This comment has been minimized.
|
Looks reasonable. |
This comment has been minimized.
This comment has been minimized.
|
cc me |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I am |
This comment has been minimized.
This comment has been minimized.
pwoolcoc
commented
Aug 24, 2016
|
I was just looking into this today, glad someone beat me to it |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Aug 24, 2016
|
I feel like this doesn't work well for the |
This comment has been minimized.
This comment has been minimized.
jseyfried
commented
Aug 24, 2016
•
|
@briansmith n.b. After #1560 is done (c.f. rust-lang/rust#35894), we won't need mod a { pub fn f() {} }
mod b { pub fn f() {} }
fn main() {
use a::*;
use b::*;
f(); // This is an error, since `f` could be `a::f` or `b::f`.
// use a::f; // uncommenting this fixes the error.
//^ Adding this is analogous to appending `hiding {f}` to `use b::*;`.
} |
This comment has been minimized.
This comment has been minimized.
I wonder if the opposite behavior is ever useful - the trait's name is in scope, but the trait doesn't participate in method/ufcs-path resolution. |
This comment has been minimized.
This comment has been minimized.
|
I have never actually wanted this behavior, but I can imagine On Wed, Aug 24, 2016 at 02:09:24AM -0700, Vadim Petrochenkov wrote:
|
This comment has been minimized.
This comment has been minimized.
|
Definitely a way to omit specific names from glob would be useful. On Tue, Aug 23, 2016 at 07:01:18PM -0700, Brian Smith wrote:
|
This comment has been minimized.
This comment has been minimized.
|
Can |
This comment has been minimized.
This comment has been minimized.
|
Can
|
This comment has been minimized.
This comment has been minimized.
jseyfried
commented
Oct 31, 2016
I think so -- it seems more consistent and could be useful. |
This comment has been minimized.
This comment has been minimized.
|
In this case |
This comment has been minimized.
This comment has been minimized.
|
RFC is proposed. #2166 |
This comment has been minimized.
This comment has been minimized.
|
Closing in favor of rust-lang/rust#48216. |
arcnmx commentedOct 8, 2015
mini/pre RFC
use some::Trait as _;This would allow importing a trait into scope for resolution reasons, without being able to reference it by ident directly.
Motivation
I've found a need for
use some::Trait as __Trait;in order to avoid conflicts with another type in scope. It tends to come up when dealing with abstractions and wrappers that have similar type names.Alternatives
use some::Trait as __Trait;use some; some::Trait::method(etc);TraitImpfor your concrete types instead.Unresolved Questions
Wildcard version?
use some::* as _could work well for importing preludes.Allow use with
pubto make them available for constructing preludes?Actual design? A simple approach might be to simply implement this as sugar for mangling the trait name in some way (ideally with the full path of the module to accomodate for
pubexporting). A real implementation would make them truly hidden as identifiers, but otherwise usable for deciding whether a trait is applicable.Would this be valid for non-trait types such as structures, type aliases, etc? I'd imagine the wildcard case would simply ignore them, but the explicit syntax would be weird and useless.