aboutsummaryrefslogtreecommitdiff
path: root/src/manager/mod.rs
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2019-09-28 18:20:33 +0000
committerHristo Venev <hristo@venev.name>2019-09-29 16:11:35 +0300
commit56d37f135536c7d17ab98c6671094925dee64a5e (patch)
tree652b972cef0c1700b4c8ee457afd7b79861f1672 /src/manager/mod.rs
parent8e6318f29eb022126e82e0c084262c77d9ee3300 (diff)
I don't like `if let` that much.
Diffstat (limited to 'src/manager/mod.rs')
-rw-r--r--src/manager/mod.rs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/manager/mod.rs b/src/manager/mod.rs
index 78d579f..aa8b792 100644
--- a/src/manager/mod.rs
+++ b/src/manager/mod.rs
@@ -95,20 +95,15 @@ impl Manager {
}
fn state_path(&self) -> Option<PathBuf> {
- let mut path = if let Some(ref path) = self.state_directory {
- path.clone()
- } else {
- return None;
- };
+ let mut path = self.state_directory.as_ref()?.clone();
path.push("state.json");
Some(path)
}
fn current_load(&mut self) -> bool {
- let path = if let Some(path) = self.state_path() {
- path
- } else {
- return false;
+ let path = match self.state_path() {
+ Some(v) => v,
+ None => return false,
};
let data = match load_file(&path) {
@@ -136,10 +131,9 @@ impl Manager {
}
fn current_update(&mut self, c: &model::Config) {
- let path = if let Some(path) = self.state_path() {
- path
- } else {
- return;
+ let path = match self.state_path() {
+ Some(v) => v,
+ None => return,
};
let data = serde_json::to_vec(c).unwrap();