From 971ce0f285dd06a618711eba8e8ed1ae7c814294 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Sat, 5 Aug 2017 02:03:30 -0700 Subject: Fix tests and put back .deserialize as deprecated --- examples/glob/src/main.rs | 6 +++--- src/config.rs | 5 +++++ 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::>().unwrap()); + settings.try_into::>().unwrap()); // Option 2 // -------- @@ -33,7 +33,7 @@ fn main() { // Print out our settings (as a HashMap) println!("\n{:?} \n\n-----------", - settings.deserialize::>().unwrap()); + settings.try_into::>().unwrap()); // Option 3 // -------- @@ -48,5 +48,5 @@ fn main() { // Print out our settings (as a HashMap) println!("\n{:?} \n\n-----------", - settings.deserialize::>().unwrap()); + settings.try_into::>().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::deserialize(self) } + + #[deprecated(since="0.7.0", note="please use 'try_into' instead")] + pub fn deserialize<'de, T: Deserialize<'de>>(self) -> Result { + 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()); -- cgit v1.2.3