I'm writing a parser combinator library. I thought maybe I could also make the parser structs functions that operate on input, but I can't get the types right. The offending code.
Earls-MacBook-Pro:farce earljstsauver$ head 10 src/parser.rs
head: 10: No such file or directory
==> src/parser.rs <==
pub trait Parser<'b>: Fn(&str, Option<&str>) {
}
impl <'a> Fn(&str, Option<&str>) for LiteralParser<'a> {
fn call(&self, args: &str) -> Option<&str> {
None
}
}
The error when I try and build it
Earls-MacBook-Pro:farce earljstsauver$ cargo build
Compiling farce v0.0.1 (file:///Users/earljstsauver/dev/rust/farce)
src/parser.rs:5:13: 5:33 error: associated type bindings are not allowed here [E0229]
src/parser.rs:5 impl <'a> Fn(&str, Option<&str>) for LiteralParser<'a> {
^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `farce`.
To learn more, run the command again with --verbose.
How do I declare that I implement a function in this case?