ju_tcs_tbop_24_bb/
lib.rs

1use std::fs::read_to_string;
2use std::path::Path;
3
4pub fn head(path: &Path, n: usize) -> Vec<String> {
5    read_to_string(path)
6        .unwrap()
7        .lines()
8        .take(n)
9        .map(String::from)
10        .collect()
11}
12
13pub fn tail(path: &Path, n: usize) -> Vec<String> {
14    let mut res: Vec<String> = read_to_string(path)
15        .unwrap()
16        .lines()
17        .rev()
18        .take(n)
19        .map(String::from)
20        .collect();
21    res.reverse();
22    res
23}