diff options
author | Ryan Leckey <leckey.ryan@gmail.com> | 2017-08-05 02:03:30 -0700 |
---|---|---|
committer | Ryan Leckey <leckey.ryan@gmail.com> | 2017-08-05 02:03:37 -0700 |
commit | 971ce0f285dd06a618711eba8e8ed1ae7c814294 (patch) | |
tree | c2c4a49f01f89e3d9e3a9b12e02514bc183faa0e | |
parent | cb4888dbbd3f2ebd1bd4e35fb07fb2fe0facafe8 (diff) |
Fix tests and put back .deserialize as deprecated0.7.0
-rw-r--r-- | examples/glob/src/main.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 5 | ||||
-rw-r--r-- | tests/get.rs | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/examples/glob/src/main.rs b/examples/glob/src/main.rs index f88f1ed..112335c 100644 --- a/examples/glob/src/main.rs +++ b/examples/glob/src/main.rs @@ -19,7 +19,7 @@ fn main() { // Print out our settings (as a HashMap) println!("\n{:?} \n\n-----------", - settings.deserialize::<HashMap<String, String>>().unwrap()); + settings.try_into::<HashMap<String, String>>().unwrap()); // Option 2 // -------- @@ -33,7 +33,7 @@ fn main() { // Print out our settings (as a HashMap) println!("\n{:?} \n\n-----------", - settings.deserialize::<HashMap<String, String>>().unwrap()); + settings.try_into::<HashMap<String, String>>().unwrap()); // Option 3 // -------- @@ -48,5 +48,5 @@ fn main() { // Print out our settings (as a HashMap) println!("\n{:?} \n\n-----------", - settings.deserialize::<HashMap<String, String>>().unwrap()); + settings.try_into::<HashMap<String, String>>().unwrap()); } diff --git a/src/config.rs b/src/config.rs index fac76a5..33d17bc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -189,6 +189,11 @@ impl Config { pub fn try_into<'de, T: Deserialize<'de>>(self) -> Result<T> { T::deserialize(self) } + + #[deprecated(since="0.7.0", note="please use 'try_into' instead")] + pub fn deserialize<'de, T: Deserialize<'de>>(self) -> Result<T> { + self.try_into() + } } impl Source for Config { diff --git a/tests/get.rs b/tests/get.rs index 995f73c..517339e 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -132,7 +132,7 @@ fn test_map_struct() { } let c = make(); - let s: Settings = c.deserialize().unwrap(); + let s: Settings = c.try_into().unwrap(); assert_eq!(s.place.len(), 7); assert_eq!( @@ -147,7 +147,7 @@ fn test_file_struct() { let c = make(); // Deserialize the entire file as single struct - let s: Settings = c.deserialize().unwrap(); + let s: Settings = c.try_into().unwrap(); assert!(s.debug.approx_eq_ulps(&1.0, 2)); assert_eq!(s.production, Some("false".to_string())); @@ -195,7 +195,7 @@ fn test_struct_array() { } let c = make(); - let s: Settings = c.deserialize().unwrap(); + let s: Settings = c.try_into().unwrap(); assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); |