pub enum SomeEnum {
A(f64),
B(f64),
C(f64),
}
impl SomeEnum {
pub fn new()
-> Self
{
Self::A(5.0) // does not compile
}
pub fn but_this_is_ok()
-> Self
{
SomeEnum::A(5.0)
}
}
This code does not compile: https://is.gd/iC0vAp
error[E0599]: no associated item named `A` found for type `SomeEnum` in the current scope
--> <anon>:11:9
|
11 | Self::A(5.0)
| ^^^^^^^
I know that rust had problems with using Self
in constructor-like functions - is this an open issue right now? All I want to do is to avoid using my enums name. Rust obviously detects that I want to use SomeEnum
, but for some reason, it doesn’t find the enum variant.