summaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
authorDaniel Eades <danieleades@hotmail.com>2022-01-29 12:14:37 +0100
committerDaniel Eades <danieleades@hotmail.com>2022-01-29 14:01:49 +0100
commit6ecfeec624ae9e145b66431188bae31c17bcd154 (patch)
tree82a552f664dd98c5e55007aff914632834810e33 /src/error.rs
parent53e43fbcf96b5c2a661d052a6e3d55fc3709f1e1 (diff)
use 'Self' to refer to own type
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/error.rs b/src/error.rs
index daeb081..f955a28 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -92,7 +92,7 @@ impl ConfigError {
unexpected: Unexpected,
expected: &'static str,
) -> Self {
- ConfigError::Type {
+ Self::Type {
origin,
unexpected,
expected,
@@ -104,8 +104,8 @@ impl ConfigError {
// TODO: for now only json5 checked, need to finish others
#[doc(hidden)]
pub fn invalid_root(origin: Option<&String>, unexpected: Unexpected) -> Box<Self> {
- Box::new(ConfigError::Type {
- origin: origin.map(|s| s.to_owned()),
+ Box::new(Self::Type {
+ origin: origin.cloned(),
unexpected,
expected: "a map",
key: None,
@@ -117,12 +117,12 @@ impl ConfigError {
#[must_use]
pub fn extend_with_key(self, key: &str) -> Self {
match self {
- ConfigError::Type {
+ Self::Type {
origin,
unexpected,
expected,
..
- } => ConfigError::Type {
+ } => Self::Type {
origin,
unexpected,
expected,
@@ -145,18 +145,18 @@ impl ConfigError {
format!("{}{}{}", segment, dot, key)
};
match self {
- ConfigError::Type {
+ Self::Type {
origin,
unexpected,
expected,
key,
- } => ConfigError::Type {
+ } => Self::Type {
origin,
unexpected,
expected,
key: Some(concat(key)),
},
- ConfigError::NotFound(key) => ConfigError::NotFound(concat(Some(key))),
+ Self::NotFound(key) => Self::NotFound(concat(Some(key))),
_ => self,
}
}
@@ -233,12 +233,12 @@ impl Error for ConfigError {}
impl de::Error for ConfigError {
fn custom<T: fmt::Display>(msg: T) -> Self {
- ConfigError::Message(msg.to_string())
+ Self::Message(msg.to_string())
}
}
impl ser::Error for ConfigError {
fn custom<T: fmt::Display>(msg: T) -> Self {
- ConfigError::Message(msg.to_string())
+ Self::Message(msg.to_string())
}
}