Advertisement
Guest User

Untitled

a guest
Sep 27th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.38 KB | None | 0 0
  1. use std::fs;
  2. use std::io::prelude::*;
  3. use std::io::BufReader;
  4. let buf = BufReader::new(fs::File::open("log.log").expect("no such file"));
  5. let lines: Vec<String> = buf
  6.     .lines()
  7.     .map(|l| l.expect("Could not parse line"))
  8.     .collect();
  9. let mut output = String::new();
  10. lines.iter().rev().take(10).rev().for_each(|line| {
  11.     output.push_str(&line);
  12.     output.push('\n');
  13. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement