diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2019-05-09 09:58:48 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2019-05-09 09:58:48 -0700 |
commit | 834480a46c9c7b3b4b0e467b592ecc209e15b84c (patch) | |
tree | 129fd4bb4fbfbb6e14b4c586c0cf069dcac53184 /src | |
parent | c03fd36f4929bcb0a0bfa8ff601cb35ffb95106e (diff) |
Remove try_defaults_from and set_defaults (for now) as '#[serde(default)]' works thanks to #106
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/src/config.rs b/src/config.rs index fa43e2a..2ce73f1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -134,26 +134,6 @@ impl Config { self.refresh() } - /// Set the configuration defaults by serializing them from given value. - pub fn set_defaults<T>(&mut self, value: &T) -> Result<&mut Config> - where - T: Serialize, - { - match self.kind { - ConfigKind::Mutable { - ref mut defaults, .. - } => { - for (key, val) in Self::try_from(&value)?.collect()? { - defaults.insert(key.parse()?, val); - } - } - - ConfigKind::Frozen => return Err(ConfigError::Frozen), - } - - self.refresh() - } - pub fn set<T>(&mut self, key: &str, value: T) -> Result<&mut Config> where T: Into<Value>, @@ -224,14 +204,6 @@ impl Config { Ok(serializer.output) } - /// Attempt to serialize the entire configuration from the given type - /// as default values. - pub fn try_defaults_from<T: Serialize>(from: &T) -> Result<Self> { - let mut c = Self::new(); - c.set_defaults(from)?; - Ok(c) - } - #[deprecated(since = "0.7.0", note = "please use 'try_into' instead")] pub fn deserialize<'de, T: Deserialize<'de>>(self) -> Result<T> { self.try_into() |