Skip to content

Can't figure out why this code won't compile #31

Open
@Keithcat1

Description

I have the following bit of code and it won't compile:
use {serde::{de::DeserializeOwned}, std::io::Read, genawaiter::{yield_, stack::let_gen}};

fn stream_iter<T: DeserializeOwned, U: Read>(reader: U) -> impl Iterator<Item=serde_json::Result> {
let_gen!(output, {
loop {
yield_!(serde_json::from_reader<U, T>(reader));
}
});
return output.into_iter();
}
fn main() {
}
The generator is supposed to read values of type T from an std::io::Read by using serde_json to deserialize the data.
The error I am getting is this:
error: no rules expected the token @
--> src\bin\stdin_json.rs:4:2
|
4 | / let_gen!(output, {
5 | | loop {
6 | | yield_!(serde_json::from_reader<U, T>(reader));
7 | | }
8 | | });
| |_______^ no rules expected this token in macro call
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro
-backtrace for more info)

error: aborting due to previous error

Thanks for the library BTW. Generators are cool!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions