From 47c0a3ca296a9b775275c2c7118a172b9f0bcc54 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 8 Apr 2019 18:23:55 +0200 Subject: clippy --- dhall/src/binary.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'dhall/src/binary.rs') diff --git a/dhall/src/binary.rs b/dhall/src/binary.rs index 87972cf..c785daf 100644 --- a/dhall/src/binary.rs +++ b/dhall/src/binary.rs @@ -237,11 +237,11 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result { }; let path = rest .map(|s| { - s.as_string().ok_or( + s.as_string().ok_or_else(|| { DecodeError::WrongFormatError( "import/remote/path".to_owned(), - ), - ) + ) + }) }) .collect::>()?; ImportLocation::Remote(URL { @@ -264,11 +264,11 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result { }; let path = rest .map(|s| { - s.as_string().ok_or( + s.as_string().ok_or_else(|| { DecodeError::WrongFormatError( "import/local/path".to_owned(), - ), - ) + ) + }) }) .collect::>()?; ImportLocation::Local(prefix, path) @@ -296,11 +296,11 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result { let mut tuples = bindings.iter().tuples(); let bindings = (&mut tuples) .map(|(x, t, v)| { - let x = x.as_string().ok_or( + let x = x.as_string().ok_or_else(|| { DecodeError::WrongFormatError( "let/label".to_owned(), - ), - )?; + ) + })?; let x = Label::from(x.as_str()); let t = match t { Null => None, @@ -310,9 +310,9 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result { Ok((x, t, v)) }) .collect::, _>>()?; - let expr = tuples.into_buffer().next().ok_or( - DecodeError::WrongFormatError("let/expr".to_owned()), - )?; + let expr = tuples.into_buffer().next().ok_or_else(|| { + DecodeError::WrongFormatError("let/expr".to_owned()) + })?; let expr = cbor_value_to_dhall(expr)?; return Ok(bindings .into_iter() @@ -334,9 +334,9 @@ fn cbor_map_to_dhall_map( ) -> Result, DecodeError> { map.iter() .map(|(k, v)| -> Result<(_, _), _> { - let k = k - .as_string() - .ok_or(DecodeError::WrongFormatError("map/key".to_owned()))?; + let k = k.as_string().ok_or_else(|| { + DecodeError::WrongFormatError("map/key".to_owned()) + })?; let v = cbor_value_to_dhall(v)?; Ok((Label::from(k.as_ref()), v)) }) -- cgit v1.2.3