Replies: 1 comment
-
impl std::str::FromStr for Derivation {
type Err = String;
fn from_str(input: &str) -> Result<Self, Self::Err> {
parse_derivation::<ContextError>.parse(input).map_err(|e| e.to_string())
}
} Unless you are building reusable parsers for others, I'd recommend hard coding the Error type to the type that you prefer, much like you hard code the Input type. Note that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background context
I am building my own parser to parse through Nix derivation (.drv) files. Source for the repository and the branch I'm currently working on can be found here djacu/nix-derivation-tools.
The exact file where I am testing things out is here: https://github.com/djacu/nix-derivation-tools/blob/switch-from-nom-to-minnow/packages/nix-derivation-parser/src/derivations/parsers.rs
Issue
I read through the tutorials and the Implementing
FromStr
topic and wanted to do the same for my project. Specifically on thisDerivation
struct.I started with something similar to the topic like this:
but was getting error like this
I tried implementing a dummy
Display
to see if that would satisfy the trait requirements like so:but that produced an even more inscrutable error.
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions