mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 13:11:15 +02:00
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:
@@ -36,11 +36,7 @@ pub fn read_trusted() -> Result<Trusted, ShellError> {
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(config_path)
|
||||
.or_else(|_| {
|
||||
Err(ShellError::untagged_runtime_error(
|
||||
"Couldn't open nu-env.toml",
|
||||
))
|
||||
})?;
|
||||
.map_err(|_| ShellError::untagged_runtime_error("Couldn't open nu-env.toml"))?;
|
||||
let mut doc = String::new();
|
||||
file.read_to_string(&mut doc)?;
|
||||
|
||||
|
@@ -54,10 +54,8 @@ impl WholeStreamCommand for AutoenvTrust {
|
||||
.insert(filename, Sha256::digest(&content).as_slice().to_vec());
|
||||
|
||||
let config_path = config::default_path_for(&Some(PathBuf::from("nu-env.toml")))?;
|
||||
let tomlstr = toml::to_string(&allowed).or_else(|_| {
|
||||
Err(ShellError::untagged_runtime_error(
|
||||
"Couldn't serialize allowed dirs to nu-env.toml",
|
||||
))
|
||||
let tomlstr = toml::to_string(&allowed).map_err(|_| {
|
||||
ShellError::untagged_runtime_error("Couldn't serialize allowed dirs to nu-env.toml")
|
||||
})?;
|
||||
fs::write(config_path, tomlstr).expect("Couldn't write to toml file");
|
||||
|
||||
|
@@ -78,10 +78,8 @@ impl WholeStreamCommand for AutoenvUnTrust {
|
||||
));
|
||||
}
|
||||
|
||||
let tomlstr = toml::to_string(&allowed).or_else(|_| {
|
||||
Err(ShellError::untagged_runtime_error(
|
||||
"Couldn't serialize allowed dirs to nu-env.toml",
|
||||
))
|
||||
let tomlstr = toml::to_string(&allowed).map_err(|_| {
|
||||
ShellError::untagged_runtime_error("Couldn't serialize allowed dirs to nu-env.toml")
|
||||
})?;
|
||||
fs::write(config_path, tomlstr).expect("Couldn't write to toml file");
|
||||
|
||||
|
@@ -141,15 +141,8 @@ fn action(input: &Value, options: &Substring, tag: impl Into<Tag>) -> Result<Val
|
||||
)
|
||||
})?;
|
||||
|
||||
let start: isize = options.0.try_into().map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
"could not perform substring",
|
||||
"could not perform substring",
|
||||
tag.span,
|
||||
)
|
||||
})?;
|
||||
|
||||
let end = options.1;
|
||||
let start: isize = options.0;
|
||||
let end: isize = options.1;
|
||||
|
||||
if start < len && end >= 0 {
|
||||
match start.cmp(&end) {
|
||||
|
Reference in New Issue
Block a user