add get nth line function
This commit is contained in:
parent
932fb2827d
commit
d81bac5146
@ -216,6 +216,15 @@ impl UserDBValidation for UserDBLocal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_nth_line(path: Option<&PathBuf>, n: u32) -> String {
|
||||||
|
let lines = file_to_string(path);
|
||||||
|
let line = lines.lines().nth(n as usize);
|
||||||
|
match line {
|
||||||
|
Some(line) => line.to_owned(),
|
||||||
|
None => "".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse a file to a string
|
/// Parse a file to a string
|
||||||
fn file_to_string(path: Option<&PathBuf>) -> String {
|
fn file_to_string(path: Option<&PathBuf>) -> String {
|
||||||
let file = File::open(path.expect("Path cannot be None".into()))
|
let file = File::open(path.expect("Path cannot be None".into()))
|
||||||
|
Loading…
Reference in New Issue
Block a user