summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-04-17 11:23:39 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-04-17 11:23:39 +0200
commit292d4743f21a3db2697d2537d871db9b58dde875 (patch)
tree613ff580921436f71e011a38f1fc80ae550cd939
parentfeed306c34c6cec86ea8f0b0cca02369aaa0659b (diff)
Make ConfigBuilder::set_{default,overwrite} take AsRef<str>szarykott-builder-patches
To be a bit more flexible here on the user side of the API, make the API take AsRef<str>, which gives the user the ability to pass `String` to the API if they want to. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/builder.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/builder.rs b/src/builder.rs
index 23090c6..8abbe54 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -77,11 +77,12 @@ impl ConfigBuilder {
/// # Errors
///
/// Fails if `Expression::from_str(key)` fails.
- pub fn set_default<T>(&mut self, key: &str, value: T) -> error::Result<&mut ConfigBuilder>
+ pub fn set_default<S, T>(&mut self, key: S, value: T) -> error::Result<&mut ConfigBuilder>
where
+ S: AsRef<str>,
T: Into<Value>,
{
- self.defaults.insert(Expression::from_str(key)?, value.into());
+ self.defaults.insert(Expression::from_str(key.as_ref())?, value.into());
Ok(self)
}
@@ -103,11 +104,12 @@ impl ConfigBuilder {
/// # Errors
///
/// Fails if `Expression::from_str(key)` fails.
- pub fn set_override<T>(&mut self, key: &str, value: T) -> error::Result<&mut ConfigBuilder>
+ pub fn set_override<S, T>(&mut self, key: S, value: T) -> error::Result<&mut ConfigBuilder>
where
+ S: AsRef<str>,
T: Into<Value>,
{
- self.overrides.insert(Expression::from_str(key)?, value.into());
+ self.overrides.insert(Expression::from_str(key.as_ref())?, value.into());
Ok(self)
}