Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call)
This commit is contained in:
parent
3fc5c118dd
commit
a1c3eb6043
@ -90,14 +90,14 @@ impl DocFS {
|
|||||||
let sender = self.errors.sender.clone().unwrap();
|
let sender = self.errors.sender.clone().unwrap();
|
||||||
rayon::spawn(move || match fs::write(&path, &contents) {
|
rayon::spawn(move || match fs::write(&path, &contents) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
sender
|
sender.send(None).unwrap_or_else(|_| {
|
||||||
.send(None)
|
panic!("failed to send error on \"{}\"", path.display())
|
||||||
.expect(&format!("failed to send error on \"{}\"", path.display()));
|
});
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
sender
|
sender.send(Some(format!("\"{}\": {}", path.display(), e))).unwrap_or_else(
|
||||||
.send(Some(format!("\"{}\": {}", path.display(), e)))
|
|_| panic!("failed to send non-error on \"{}\"", path.display()),
|
||||||
.expect(&format!("failed to send non-error on \"{}\"", path.display()));
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -158,7 +158,7 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) {
|
|||||||
.filter(|test| test.desc.name.as_slice() == name)
|
.filter(|test| test.desc.name.as_slice() == name)
|
||||||
.map(make_owned_test)
|
.map(make_owned_test)
|
||||||
.next()
|
.next()
|
||||||
.expect(&format!("couldn't find a test with the provided name '{}'", name));
|
.unwrap_or_else(|| panic!("couldn't find a test with the provided name '{}'", name));
|
||||||
let TestDescAndFn { desc, testfn } = test;
|
let TestDescAndFn { desc, testfn } = test;
|
||||||
let testfn = match testfn {
|
let testfn = match testfn {
|
||||||
StaticTestFn(f) => f,
|
StaticTestFn(f) => f,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user