summaryrefslogtreecommitdiffstats
path: root/src/marks.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-10-20 23:36:21 +0200
committerqkzk <qu3nt1n@gmail.com>2022-10-20 23:36:21 +0200
commitf46684a2792eee1ed2dbcdf9aabeaef9b993af35 (patch)
tree2b4b650668a81a837588adffd6082a1e217fc4d0 /src/marks.rs
parenteae8ca6a61dbcb59430ac1b8409a439ee4112d4d (diff)
remove some unwraps
Diffstat (limited to 'src/marks.rs')
-rw-r--r--src/marks.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/marks.rs b/src/marks.rs
index 09a0501..ca02d7d 100644
--- a/src/marks.rs
+++ b/src/marks.rs
@@ -35,7 +35,7 @@ impl Marks {
fn parse_line(line: Result<String, io::Error>) -> Result<(char, PathBuf), io::Error> {
let line = line?;
- let sp: Vec<&str> = line.split(":").collect();
+ let sp: Vec<&str> = line.split(':').collect();
if let Some(ch) = sp[0].chars().next() {
let path = PathBuf::from(sp[1]);
Ok((ch, path))
@@ -69,11 +69,8 @@ impl Marks {
}
}
- fn path_as_string(path: &PathBuf) -> String {
- path.clone()
- .into_os_string()
- .into_string()
- .unwrap_or("".to_owned())
+ fn path_as_string(path: &Path) -> String {
+ path.to_str().unwrap_or("").to_owned()
}
pub fn as_strings(&self) -> Vec<String> {
@@ -83,11 +80,11 @@ impl Marks {
.collect()
}
- fn format_mark(ch: &char, path: &PathBuf) -> String {
+ fn format_mark(ch: &char, path: &Path) -> String {
let mut s = "".to_owned();
s.push(*ch);
s.push_str(" ");
- s.push_str(&path.clone().into_os_string().into_string().unwrap());
+ s.push_str(path.to_str().unwrap_or(""));
s.push('\n');
s
}