summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs8
-rw-r--r--src/ser.rs4
-rw-r--r--src/value.rs14
3 files changed, 13 insertions, 13 deletions
diff --git a/src/config.rs b/src/config.rs
index 1019061..99216ad 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -227,20 +227,20 @@ impl Config {
}
/// Attempt to deserialize the entire configuration into the requested type.
- pub fn try_into<'de, T: Deserialize<'de>>(self) -> Result<T> {
+ pub fn try_deserialize<'de, T: Deserialize<'de>>(self) -> Result<T> {
T::deserialize(self)
}
/// Attempt to serialize the entire configuration from the given type.
- pub fn try_from<T: Serialize>(from: &T) -> Result<Self> {
+ pub fn try_serialize<T: Serialize>(from: &T) -> Result<Self> {
let mut serializer = ConfigSerializer::default();
from.serialize(&mut serializer)?;
Ok(serializer.output)
}
- #[deprecated(since = "0.7.0", note = "please use 'try_into' instead")]
+ #[deprecated(since = "0.7.0", note = "please use 'try_deserialize' instead")]
pub fn deserialize<'de, T: Deserialize<'de>>(self) -> Result<T> {
- self.try_into()
+ self.try_deserialize()
}
}
diff --git a/src/ser.rs b/src/ser.rs
index 39c02b9..ce016bf 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -710,9 +710,9 @@ mod test {
int: 1,
seq: vec!["a".to_string(), "b".to_string()],
};
- let config = Config::try_from(&test).unwrap();
+ let config = Config::try_serialize(&test).unwrap();
- let actual: Test = config.try_into().unwrap();
+ let actual: Test = config.try_deserialize().unwrap();
assert_eq!(test, actual);
}
}
diff --git a/src/value.rs b/src/value.rs
index 177acf7..700279b 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -151,12 +151,12 @@ impl Value {
}
/// Attempt to deserialize this value into the requested type.
- pub fn try_into<'de, T: Deserialize<'de>>(self) -> Result<T> {
+ pub fn try_deserialize<'de, T: Deserialize<'de>>(self) -> Result<T> {
T::deserialize(self)
}
/// Returns `self` as a bool, if possible.
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_bool(self) -> Result<bool> {
match self.kind {
ValueKind::Boolean(value) => Ok(value),
@@ -197,7 +197,7 @@ impl Value {
}
/// Returns `self` into an i64, if possible.
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_int(self) -> Result<i64> {
match self.kind {
ValueKind::Integer(value) => Ok(value),
@@ -242,7 +242,7 @@ impl Value {
}
/// Returns `self` into a f64, if possible.
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_float(self) -> Result<f64> {
match self.kind {
ValueKind::Float(value) => Ok(value),
@@ -287,7 +287,7 @@ impl Value {
}
/// Returns `self` into a str, if possible.
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_str(self) -> Result<String> {
match self.kind {
ValueKind::String(value) => Ok(value),
@@ -316,7 +316,7 @@ impl Value {
}
/// Returns `self` into an array, if possible
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_array(self) -> Result<Vec<Value>> {
match self.kind {
ValueKind::Array(value) => Ok(value),
@@ -356,7 +356,7 @@ impl Value {
}
/// If the `Value` is a Table, returns the associated Map.
- // FIXME: Should this not be `try_into_*` ?
+ // FIXME: Should this not be `try_deserialize_*` ?
pub fn into_table(self) -> Result<HashMap<String, Value>> {
match self.kind {
ValueKind::Table(value) => Ok(value),