1

I have the following method in Rust:

   pub fn parse<B: BufRead>(buf: B) -> anyhow::Result<Self> {
        let mut lines = buf.lines();

        // do stuff with lines

        let mut body_buf = vec![0; content_length];
        buf.read_exact(&mut body_buf[..]);

        // do stuff with body_buf
    }

But it's not working because buf.lines() consumes self. Is there a way to get a line-by-line iterator that does not consume self?

laptou
  • 6,389
  • 2
  • 28
  • 59

0 Answers0