Use '?' for error propagation, remove match (#2194)

This commit is contained in:
Joseph T. Lyons 2020-07-16 13:39:51 -04:00 committed by GitHub
parent a04dfca63a
commit 0f688d7da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 23 additions and 118 deletions

View File

@ -67,17 +67,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => return Err(err),
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -67,19 +67,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -87,19 +87,10 @@ async fn operate(
for path in &column_paths {
let options = options.clone();
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, &options, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -100,18 +100,10 @@ async fn operate(
} else {
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag(), digits, group_digits)),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -80,19 +80,10 @@ async fn operate(
for path in &column_paths {
let options = options.clone();
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, &options, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -115,19 +115,10 @@ async fn operate(
for path in &column_paths {
let options = options.clone();
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, &options, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -87,19 +87,11 @@ async fn operate(
for path in &column_paths {
let options = options.clone();
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, &options, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -70,19 +70,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -70,19 +70,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -84,19 +84,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag(), to_trim)),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)

View File

@ -67,19 +67,10 @@ async fn operate(
let mut ret = v;
for path in &column_paths {
let swapping = ret.swap_data_by_column_path(
ret = ret.swap_data_by_column_path(
path,
Box::new(move |old| action(old, old.tag())),
);
match swapping {
Ok(new_value) => {
ret = new_value;
}
Err(err) => {
return Err(err);
}
}
)?;
}
ReturnSuccess::value(ret)