Silence Rust 1.45 Clippy warnings (#2196)

* Silence Rust 1.45 Clippy warnings dealing with using `map_err()`

* Silence false Clippy warning

* Fix last Clippy error for unnecessary conversion

* Fix `and_then` clippy warnings
This commit is contained in:
Joseph T. Lyons
2020-07-17 13:57:15 -04:00
committed by GitHub
parent 0f688d7da7
commit f26151e36d
6 changed files with 17 additions and 32 deletions

View File

@@ -55,7 +55,7 @@ impl DirectorySpecificEnvironment {
if autoenv::file_is_trusted(&nu_env_file, &content)? {
let mut doc: NuEnvDoc = toml::de::from_slice(&content)
.or_else(|e| Err(ShellError::untagged_runtime_error(format!("{:?}", e))))?;
.map_err(|e| ShellError::untagged_runtime_error(format!("{:?}", e)))?;
if let Some(scripts) = doc.scripts.as_ref() {
for (k, v) in scripts {
@@ -244,11 +244,11 @@ fn value_from_script(cmd: &str) -> Result<String, ShellError> {
cmd
)));
}
let response = std::str::from_utf8(&command.stdout[..command.stdout.len()]).or_else(|e| {
Err(ShellError::untagged_runtime_error(format!(
let response = std::str::from_utf8(&command.stdout[..command.stdout.len()]).map_err(|e| {
ShellError::untagged_runtime_error(format!(
"Couldn't parse stdout from command {:?}: {:?}",
command, e
)))
))
})?;
Ok(response.trim().to_string())