pub fn readlines(fname: &str) -> Result<Vec<String>>Expand description
Reads all the lines of a file and returns them in a vector.
It is similar to Python’s f.readlines(), where f is a file handler.
§Examples
let lines: Vec<String> = jabba_lib::jfs::readlines("Cargo.toml").unwrap();Examples found in repository?
examples/fs.rs (line 5)
4fn main() {
5 let lines = jfs::readlines("Cargo.toml").unwrap();
6 println!("Number of lines in Cargo.toml: {}", lines.len());
7 println!("---");
8 let content = jfs::read("Cargo.toml").unwrap();
9 println!("Number of characters in Cargo.toml: {}", content.len());
10 println!("---");
11 let f = jfs::open("Cargo.toml").unwrap();
12 for line in f.lines() {
13 let line = line.unwrap();
14 println!("{}", line);
15 }
16}