Skip to content

Instantly share code, notes, and snippets.

@vadixidav
Created October 22, 2017 22:17
Show Gist options
  • Save vadixidav/6a2c123b94f3257fb81c2db7d47ab918 to your computer and use it in GitHub Desktop.
Save vadixidav/6a2c123b94f3257fb81c2db7d47ab918 to your computer and use it in GitHub Desktop.
```rust
fn fold_op<F: Fn(f64, f64)>(input: &[u8], init: f64, f: F) -> IResult<&[u8], f64> {
    fold_many0!(ws!(alt!(apply!(list) | apply!(f64::from_str))), init, f)
}
named!(list<f64>, delimited!(tag!("("), ws!(alt!(
    proceed!(tag!("+"), apply!(fop, 0.0, |acc, item| acc + item))
)), tag!(")")));
```

```
error: unexpected end of macro invocation

--> src\main.rs:19:76 | 19 | fold_many0!(ws!(alt!(apply!(list) | apply!(f64::from_str))), init, f) | ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment