diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 8c7565da..1e5f5770 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -154,7 +154,9 @@ impl< fn visit_str(&mut self, v: &str) -> Result where E: Error, { - str::FromStr::from_str(v.trim()).or(Err(Error::type_mismatch(Type::Str))) + str::FromStr::from_str(v.trim()).or_else(|_| { + Err(Error::type_mismatch(Type::Str)) + }) } }