This implements the Read
trait, calling a function
to generate the data.
See the API documentation.
Import Crate
read_with="0.1"
Example
let mut output = vec!();
let many_strings = ["one", "two", "three"];
let mut pos = 0;
std::io::copy(
&mut ReadWith::new(
||
{
if pos == many_strings.len() { return None; }
let o = many_strings[pos];
pos+=1;
Some(o)
}
),
&mut output,
).unwrap();
assert_eq!("onetwothree", str::from_utf8(&output).unwrap());