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| {
let bin_name = {
if let Some(name) = path.file_name() {
match name.to_str() {
Some(raw) => raw,
None => "",
}
name.to_str().unwrap_or("")
} else {
""
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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