dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
965 stars 164 forks source link

Make Iterator implementation of Deserializer::from_reader lazy #390

Open quilir opened 1 year ago

quilir commented 1 year ago

The current implementation of Iterator for Deserializer created by from_reader constructor is eager. Upon calling next() for the first time, it uses Loader to load all the contents via read_to_end() on reader.

Such implementation is unfortunate for two reasons:

I suggest loading only a single document from the reader at the time when calling next(). It could replace the current implementation or be optional feature accessible only by, for example, from_reader_lazy() constructor