clippy: fix or_fun_call warnings

This commit is contained in:
Philippe Renon 2020-10-26 14:07:52 +01:00
parent 5dff493515
commit d577a18a45

View File

@ -196,7 +196,7 @@ where
SB: Storage<N, U1, C>, SB: Storage<N, U1, C>,
{ {
assert!(rows.len() > 0, "At least one row must be given."); assert!(rows.len() > 0, "At least one row must be given.");
let nrows = R::try_to_usize().unwrap_or(rows.len()); let nrows = R::try_to_usize().unwrap_or_else(|| rows.len());
let ncols = rows[0].len(); let ncols = rows[0].len();
assert!( assert!(
rows.len() == nrows, rows.len() == nrows,
@ -803,8 +803,8 @@ where
{ {
#[inline] #[inline]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> MatrixMN<N, R, C> { fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> MatrixMN<N, R, C> {
let nrows = R::try_to_usize().unwrap_or(rng.gen_range(0, 10)); let nrows = R::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10));
let ncols = C::try_to_usize().unwrap_or(rng.gen_range(0, 10)); let ncols = C::try_to_usize().unwrap_or_else(|| rng.gen_range(0, 10));
MatrixMN::from_fn_generic(R::from_usize(nrows), C::from_usize(ncols), |_, _| rng.gen()) MatrixMN::from_fn_generic(R::from_usize(nrows), C::from_usize(ncols), |_, _| rng.gen())
} }