I am writing a method which would parse content of a file. For testing purposes, I would like to pass a &str
to this method.
I was not able to find a way to do this, but there probably is some trait which does this. Maybe a different approach is required?
So far I have this:
fn read_buff<R: Read>(buffer: BufReader<R>) {}
This fails to compile:
let s = "str";
let mut reader = BufReader::new(s); // fails to compile.
read_buff(reader);
It would be best if I had access to the methods provided by the BufReader
such as read_line
.