-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Description
I am trying to create a method on an enum, like this:
enum Foo {
Bar(String),
Baz
}
impl Foo {
pub fn get_bar(self) -> Option<String> {
match self {
// vvvv error occurs
Self::Bar(s) => Some(s),
_ => None,
}
}
}
An error occurs: No variant named 'Bar' found for type 'foo::Foo' in the current scope
Is this intended behavior? If so, it should be made more clear. At least provide a better error message.
Honestly, if this isn't "implemented" yet, then it should be because it would make a better user experience.
edit (x2): formatting
leonardo-m
Metadata
Metadata
Assignees
Labels
No labels