Match cleanup (#2184)

* Use `unwrap_or()` to remove `match`

* Use `?` for error propogation, and remove `match`
This commit is contained in:
Joseph T. Lyons 2020-07-15 03:51:41 -04:00 committed by GitHub
parent c299d207f7
commit 7c0a830d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 13 additions and 52 deletions

View file

@ -149,10 +149,7 @@ pub fn load_plugins(context: &mut Context) -> Result<(), ShellError> {
.map(|path| { .map(|path| {
let bin_name = { let bin_name = {
if let Some(name) = path.file_name() { if let Some(name) = path.file_name() {
match name.to_str() { name.to_str().unwrap_or("")
Some(raw) => raw,
None => "",
}
} else { } else {
"" ""
} }

View file

@ -62,10 +62,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag()) { ReturnSuccess::value(action(&v, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -62,10 +62,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag()) { ReturnSuccess::value(action(&v, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -80,10 +80,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, &options, v.tag()) { ReturnSuccess::value(action(&v, &options, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -96,10 +96,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag(), digits, group_digits) { ReturnSuccess::value(action(&v, v.tag(), digits, group_digits)?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;
for path in &column_paths { for path in &column_paths {

View file

@ -73,10 +73,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, &options, v.tag()) { ReturnSuccess::value(action(&v, &options, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -108,10 +108,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, &options, v.tag()) { ReturnSuccess::value(action(&v, &options, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -81,10 +81,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, &options, v.tag()) { ReturnSuccess::value(action(&v, &options, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -65,10 +65,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag()) { ReturnSuccess::value(action(&v, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -65,10 +65,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag()) { ReturnSuccess::value(action(&v, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -79,10 +79,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag(), to_trim) { ReturnSuccess::value(action(&v, v.tag(), to_trim)?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -62,10 +62,7 @@ async fn operate(
Ok(input Ok(input
.map(move |v| { .map(move |v| {
if column_paths.is_empty() { if column_paths.is_empty() {
match action(&v, v.tag()) { ReturnSuccess::value(action(&v, v.tag())?)
Ok(out) => ReturnSuccess::value(out),
Err(err) => Err(err),
}
} else { } else {
let mut ret = v; let mut ret = v;

View file

@ -37,10 +37,7 @@ impl ValueStructure {
} }
let path = if path.starts_with("/") { let path = if path.starts_with("/") {
match path.strip_prefix("/") { path.strip_prefix("/").unwrap_or(path)
Ok(p) => p,
Err(_) => path,
}
} else { } else {
path path
}; };