diff --git a/src/main.rs b/src/main.rs index 9dce40a..76481f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,11 @@ struct Nuudel { buffer: String, } +#[derive(Default)] +struct Buffer { + lines: Vec, +} + fn main() -> Result<()> { // Setup panic handling let default_panic = panic::take_hook(); @@ -113,12 +118,11 @@ impl Nuudel { let mut lines = self.buffer.lines(); while y < terminal::size()?.1-1 { stdout.execute(terminal::Clear(terminal::ClearType::CurrentLine))?; - let line = lines.next(); - if line.is_none() { + if let Some(line) = lines.next() { + write!(stdout, "{}", line)?; + } else { break; - } - write!(stdout, "{}", line.unwrap())?; - stdout.execute(cursor::MoveToNextLine(1))?; + } stdout.execute(cursor::MoveToNextLine(1))?; y += 1; } print!("Press Q to quit");