diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-03-22 11:33:09 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-03-22 11:33:09 +0100 |
commit | a533d1e81d683eb0e1679f084c604d0674b5e130 (patch) | |
tree | 8284e393a0e91f1d46cbbbd0fe8141282d270ab1 /core | |
parent | 2ac59632525d4997bfc2b9ce08fa9cf75d57d8a7 (diff) |
openpgp, core: Return old value in setters.
- Fixes #147.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/lib.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/core/src/lib.rs b/core/src/lib.rs index e261c64e..955496a1 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -233,8 +233,8 @@ impl Config { } /// Sets the directory containing shared state. - pub fn set_home<P: AsRef<Path>>(&mut self, home: P) { - self.0.home = PathBuf::new().join(home); + pub fn set_home<P: AsRef<Path>>(&mut self, home: P) -> PathBuf { + ::std::mem::replace(&mut self.0.home, PathBuf::new().join(home)) } /// Sets the directory containing backend servers. @@ -244,8 +244,8 @@ impl Config { } /// Sets the directory containing shared state. - pub fn set_lib<P: AsRef<Path>>(&mut self, lib: P) { - self.0.lib = PathBuf::new().join(lib); + pub fn set_lib<P: AsRef<Path>>(&mut self, lib: P) -> PathBuf { + ::std::mem::replace(&mut self.0.lib, PathBuf::new().join(lib)) } /// Sets the network policy. @@ -255,8 +255,9 @@ impl Config { } /// Sets the network policy. - pub fn set_network_policy(&mut self, policy: NetworkPolicy) { - self.0.network_policy = policy; + pub fn set_network_policy(&mut self, policy: NetworkPolicy) -> NetworkPolicy + { + ::std::mem::replace(&mut self.0.network_policy, policy) } /// Sets the IPC policy. @@ -266,8 +267,8 @@ impl Config { } /// Sets the IPC policy. - pub fn set_ipc_policy(&mut self, policy: IPCPolicy) { - self.0.ipc_policy = policy; + pub fn set_ipc_policy(&mut self, policy: IPCPolicy) -> IPCPolicy { + ::std::mem::replace(&mut self.0.ipc_policy, policy) } /// Makes this context ephemeral. @@ -277,8 +278,8 @@ impl Config { } /// Makes this context ephemeral. - pub fn set_ephemeral(&mut self) { - self.0.ephemeral = true; + pub fn set_ephemeral(&mut self) -> bool { + ::std::mem::replace(&mut self.0.ephemeral, true) } } |