I am trying to parse a text file and find if a string is equal to current line I am on using BufReader
:
let mut chapter = String::from("Chapter 1\n");
//open file
let file = File::open("document.txt")?;
let reader = BufReader::new(file);
for line in reader.lines() {
if chapter.eq(&line.unwrap()) {
println!("chapter found!");
}
}
However, the if statement never returns true. How can I properly convert line
from reader.lines()
into a way I can find a match?