aboutsummaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-06-05 07:46:17 +0200
committerAlex Crichton <alex@alexcrichton.com>2016-06-05 07:46:17 +0200
commitfb8050d2d556dd613971f15e7bd73cfd43acad82 (patch)
treeeaae854e5e6d5b61e9039d30217f821a8a2f30f7 /src/decoder
parent7363dbe7f599a2373e6e2a749f51c76469dabdcf (diff)
parente8097b14f1ea246bf97af380670c502ba1517f30 (diff)
downloadmilf-rs-fb8050d2d556dd613971f15e7bd73cfd43acad82.tar.gz
milf-rs-fb8050d2d556dd613971f15e7bd73cfd43acad82.zip
Merge pull request #101 from leodasvacas/clippy-run
Clippy run and implement Default for State and Enconder
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/mod.rs6
-rw-r--r--src/decoder/rustc_serialize.rs4
2 files changed, 5 insertions, 5 deletions
diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs
index a596280..b223e03 100644
--- a/src/decoder/mod.rs
+++ b/src/decoder/mod.rs
@@ -126,11 +126,11 @@ impl Decoder {
fn sub_decoder(&self, toml: Option<Value>, field: &str) -> Decoder {
Decoder {
toml: toml,
- cur_field: if field.len() == 0 {
+ cur_field: if field.is_empty() {
self.cur_field.clone()
} else {
match self.cur_field {
- None => Some(format!("{}", field)),
+ None => Some(field.to_string()),
Some(ref s) => Some(format!("{}.{}", s, field))
}
},
@@ -172,7 +172,7 @@ impl fmt::Display for DecodeError {
ExpectedType(expected, found) => {
fn humanize(s: &str) -> String {
if s == "section" {
- format!("a section")
+ "a section".to_string()
} else {
format!("a value of type `{}`", s)
}
diff --git a/src/decoder/rustc_serialize.rs b/src/decoder/rustc_serialize.rs
index 2f4fb09..f850663 100644
--- a/src/decoder/rustc_serialize.rs
+++ b/src/decoder/rustc_serialize.rs
@@ -171,7 +171,7 @@ impl rustc_serialize::Decoder for Decoder {
-> Result<T, DecodeError>
where F: FnOnce(&mut Decoder) -> Result<T, DecodeError>
{
- let field = format!("{}", f_name);
+ let field = f_name.to_string();
let toml = match self.toml {
Some(Value::Table(ref mut table)) => {
table.remove(&field)
@@ -324,7 +324,7 @@ impl rustc_serialize::Decoder for Decoder {
fn error(&mut self, err: &str) -> DecodeError {
DecodeError {
field: self.cur_field.clone(),
- kind: ApplicationError(format!("{}", err))
+ kind: ApplicationError(err.to_string())
}
}
}