-
Couldn't load subscription status.
- Fork 13.9k
Closed as duplicate
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
enum namespacing was introduced in RFC 390, which makes the following code compiles:
enum Emm {
A,
B,
}
fn main() {
use Emm::*;
let a = A;
let b = B;
}However:
struct Emm;
impl Emm {
const A: usize = 0;
const B: usize = 1;
}
fn main() {
// Compiles
let a = Emm::A;
let b = Emm::B;
// Doesn't compile
use Emm::*;
let a = A;
let b = B;
}I think it would be usefule if we have namespacing of member in impl? I met this issue on using bitflags, which depends on the feature of declaring const value in an impl block. Without namespacing of impl member we get this result:
use bitflags::bitflags;
bitflags! {
struct Flags: u32 {
const A = 0b00000001;
const B = 0b00000010;
}
}
fn main() {
// Compiles
let e = Flags::A | Flags::B;
// Doesn't compile
use Flags::*;
let e = A | B;
}Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team