summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-28 21:29:25 +0200
committerGitHub <noreply@github.com>2021-03-28 21:29:25 +0200
commite8dccf2850bc5ca7952cd267745ee3f2afa4d744 (patch)
tree84a1ef8450f48f199e97131a75a9240910193318
parent225005994d46e634918568b9013cfae82c491a8a (diff)
parent7687476f9b3b478e17e72a63b2a45d12d92e348d (diff)
Merge pull request #189 from alerque/func-rename
Rename get_str() → get_string() to match returned type
-rw-r--r--src/config.rs4
-rw-r--r--src/de.rs8
-rw-r--r--src/value.rs4
-rw-r--r--tests/file_hjson.rs2
-rw-r--r--tests/file_json.rs6
-rw-r--r--tests/file_toml.rs2
-rw-r--r--tests/file_yaml.rs2
-rw-r--r--tests/get.rs4
8 files changed, 16 insertions, 16 deletions
diff --git a/src/config.rs b/src/config.rs
index 94658da..0377438 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -211,8 +211,8 @@ impl Config {
}
}
- pub fn get_str(&self, key: &str) -> Result<String> {
- self.get(key).and_then(Value::into_str)
+ pub fn get_string(&self, key: &str) -> Result<String> {
+ self.get(key).and_then(Value::into_string)
}
pub fn get_int(&self, key: &str) -> Result<i64> {
diff --git a/src/de.rs b/src/de.rs
index c4fdeb2..0e88642 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -89,12 +89,12 @@ impl<'de> de::Deserializer<'de> for Value {
#[inline]
fn deserialize_str<V: de::Visitor<'de>>(self, visitor: V) -> Result<V::Value> {
- visitor.visit_string(self.into_str()?)
+ visitor.visit_string(self.into_string()?)
}
#[inline]
fn deserialize_string<V: de::Visitor<'de>>(self, visitor: V) -> Result<V::Value> {
- visitor.visit_string(self.into_str()?)
+ visitor.visit_string(self.into_string()?)
}
#[inline]
@@ -421,12 +421,12 @@ impl<'de> de::Deserializer<'de> for Config {
#[inline]
fn deserialize_str<V: de::Visitor<'de>>(self, visitor: V) -> Result<V::Value> {
- visitor.visit_string(self.cache.into_str()?)
+ visitor.visit_string(self.cache.into_string()?)
}
#[inline]
fn deserialize_string<V: de::Visitor<'de>>(self, visitor: V) -> Result<V::Value> {
- visitor.visit_string(self.cache.into_str()?)
+ visitor.visit_string(self.cache.into_string()?)
}
#[inline]
diff --git a/src/value.rs b/src/value.rs
index 177acf7..602b40a 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -286,9 +286,9 @@ impl Value {
}
}
- /// Returns `self` into a str, if possible.
+ /// Returns `self` into a string, if possible.
// FIXME: Should this not be `try_into_*` ?
- pub fn into_str(self) -> Result<String> {
+ pub fn into_string(self) -> Result<String> {
match self.kind {
ValueKind::String(value) => Ok(value),
diff --git a/tests/file_hjson.rs b/tests/file_hjson.rs
index 87318eb..b76ccb5 100644
--- a/tests/file_hjson.rs
+++ b/tests/file_hjson.rs
@@ -60,7 +60,7 @@ fn test_file() {
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
assert_eq!(
- s.place.creator["name"].clone().into_str().unwrap(),
+ s.place.creator["name"].clone().into_string().unwrap(),
"John Smith".to_string()
);
}
diff --git a/tests/file_json.rs b/tests/file_json.rs
index 2c614e1..b8dcbf0 100644
--- a/tests/file_json.rs
+++ b/tests/file_json.rs
@@ -60,7 +60,7 @@ fn test_file() {
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
assert_eq!(
- s.place.creator["name"].clone().into_str().unwrap(),
+ s.place.creator["name"].clone().into_string().unwrap(),
"John Smith".to_string()
);
}
@@ -98,7 +98,7 @@ fn test_json_vec() {
let v = c.get_array("WASTE").unwrap();
let mut vi = v.into_iter();
- assert_eq!(vi.next().unwrap().into_str().unwrap(), "example_dir1");
- assert_eq!(vi.next().unwrap().into_str().unwrap(), "example_dir2");
+ assert_eq!(vi.next().unwrap().into_string().unwrap(), "example_dir1");
+ assert_eq!(vi.next().unwrap().into_string().unwrap(), "example_dir2");
assert!(vi.next().is_none());
}
diff --git a/tests/file_toml.rs b/tests/file_toml.rs
index 834499f..de52548 100644
--- a/tests/file_toml.rs
+++ b/tests/file_toml.rs
@@ -71,7 +71,7 @@ fn test_file() {
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
assert_eq!(
- s.place.creator["name"].clone().into_str().unwrap(),
+ s.place.creator["name"].clone().into_string().unwrap(),
"John Smith".to_string()
);
}
diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs
index 59174e6..892875e 100644
--- a/tests/file_yaml.rs
+++ b/tests/file_yaml.rs
@@ -60,7 +60,7 @@ fn test_file() {
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
assert_eq!(
- s.place.creator["name"].clone().into_str().unwrap(),
+ s.place.creator["name"].clone().into_string().unwrap(),
"John Smith".to_string()
);
}
diff --git a/tests/get.rs b/tests/get.rs
index 10ec066..8d6db51 100644
--- a/tests/get.rs
+++ b/tests/get.rs
@@ -111,7 +111,7 @@ fn test_map() {
assert_eq!(m.len(), 8);
assert_eq!(
- m["name"].clone().into_str().unwrap(),
+ m["name"].clone().into_string().unwrap(),
"Torre di Pisa".to_string()
);
assert_eq!(m["reviews"].clone().into_int().unwrap(), 3866);
@@ -138,7 +138,7 @@ fn test_map_struct() {
assert_eq!(s.place.len(), 8);
assert_eq!(
- s.place["name"].clone().into_str().unwrap(),
+ s.place["name"].clone().into_string().unwrap(),
"Torre di Pisa".to_string()
);
assert_eq!(s.place["reviews"].clone().into_int().unwrap(), 3866);