Open JimLynchCodes opened 1 year ago
You don't need to import the trait for the derive macro to work, so you can remove the use std::str::FromStr;
line from the types file unless you need it there for a different reason. In order to use a trait method like from_str(&str)
, the corresponding trait needs to be in scope, so you need to add the use std::str::FromStr;
line to the prompt coordinator file.
I highly recommend using cargo clippy
for problems like this, since it almost always provides really good solutions and helps you understand what's going on.
Hi, sorry if this is a dumb question, but I find the giant comment code block in the strum docs to be very confusing...
What does the comment mean by "generated code"? Generated from what? Am I supposed to copy-paste this code somewhere? What is the point of showing this in the docs?
Also, in the docs is says FromStr is "autoderived", but I am getting an error that it's not found...
Here is my enum:
I then try to get a variable of my small variant from a string:
But it gives me this compiler error:
What?? I thought it was auto-derived!!?
Do I need to manually add this from_str function with an impl block? Or somehow explicitly tell it to derive FromStr in addition to the derive macros I'm already using? 🤔
Thanks!