Closed
Description
The variant of an enumeration has the same name as the function implemented for it, but this does not conflict and cannot call this function
Example
fn main() {
let _x = Foo::Value(0, ());
//let _y = Foo::Value(0); // error
}
pub enum Foo {
Value(usize, ()),
Nil
}
impl Foo {
/// It cannot be used, and no errors!!
#[allow(non_snake_case)]
pub fn Value(num: usize) -> Self {
Self::Value(num, ())
}
}
Info
cargo check
no errors and warnings.rustc --version
:rustc 1.70.0 (90c541806 2023-05-31)
rustc +nightly --version
:rustc 1.72.0-nightly (fe7454bf4 2023-06-19)
Expected
error[E0592]: duplicate definitions with name 'Value'
or this function can be called