aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Swanson <maswanso@Akamai.com>2016-05-30 16:09:40 -0400
committerMark Swanson <maswanso@Akamai.com>2016-05-30 16:09:40 -0400
commit010e34f63756ae7b83584b5f9cd79a85308b52eb (patch)
treed10cf24f577a6eae28d16f9dd002774315f927b8 /src
parent44fc9d9f37cd1b2e3d9170d04fd0a8a04d7884ff (diff)
downloadmilf-rs-010e34f63756ae7b83584b5f9cd79a85308b52eb.tar.gz
milf-rs-010e34f63756ae7b83584b5f9cd79a85308b52eb.zip
lookup() and lookup_mut() lifetime enhancements.
Rationale: - The path has nothing to do with the result. - The path has no need to live as long as the Value/self. - In some cases it can be hard to actually build a path that meets the same lifetime requirements as the Value or String slice result.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 21b3e21..6e74421 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -180,7 +180,7 @@ impl Value {
/// let no_bar = value.lookup("test.bar");
/// assert_eq!(no_bar.is_none(), true);
/// ```
- pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value> {
+ pub fn lookup<'a, 'b>(&'a self, path: &'b str) -> Option<&'a Value> {
let ref path = match Parser::new(path).lookup() {
Some(path) => path,
None => return None,
@@ -240,7 +240,7 @@ impl Value {
/// let result = value.lookup_mut("test.foo").unwrap();
/// assert_eq!(result.as_str().unwrap(), "foo");
/// ```
- pub fn lookup_mut(&mut self, path: &str) -> Option<&mut Value> {
+ pub fn lookup_mut<'a, 'b>(&'a mut self, path: &'b str) -> Option<&'a mut Value> {
let ref path = match Parser::new(path).lookup() {
Some(path) => path,
None => return None,