diff options
author | Blaž Hrastnik | 2021-10-28 01:50:17 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-10-28 01:50:17 +0000 |
commit | 3e69a4852eb9914ced7438c0788170c43756d741 (patch) | |
tree | 3128f40c17c3e43d9648e7929574d5f24614af03 | |
parent | 0a38983ee3d4a38a026dfb44ae9cd99f66145d3d (diff) |
Simplify set_path
-rw-r--r-- | helix-view/src/document.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 4d779656..27a19f3c 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -554,11 +554,9 @@ impl Document { } pub fn set_path(&mut self, path: Option<&Path>) -> Result<(), std::io::Error> { - let path = if let Some(p) = path { - Some(helix_core::path::get_canonicalized_path(p)?) - } else { - path.map(|p| p.into()) - }; + let path = path + .map(|path| helix_core::path::get_canonicalized_path(path)) + .transpose()?; // if parent doesn't exist we still want to open the document // and error out when document is saved |