Skip to content

Commit 91c0cc6

Browse files
committed
fixed several clippy issues
1 parent f9bc0e9 commit 91c0cc6

12 files changed

Lines changed: 28 additions & 34 deletions

File tree

src/algorithms/convolution/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ pub mod generic_tests {
454454

455455
use super::*;
456456
use crate::homomorphism::*;
457-
use crate::ring::*;
458457

459458
pub fn test_convolution<C, R>(convolution: C, ring: R, scale: El<R>)
460459
where

src/algorithms/fft/factor_fft.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ use crate::algorithms::fft::bluestein::BluesteinFFT;
408408
#[cfg(test)]
409409
use crate::algorithms::unity_root::*;
410410
#[cfg(test)]
411-
use crate::rings::zn::ZnRingStore;
412-
#[cfg(test)]
413411
use crate::rings::zn::zn_64;
414412
#[cfg(test)]
415413
use crate::rings::zn::zn_static::{Fp, Zn};

src/algorithms/splitting_field.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,8 @@ fn test_extend_field() {
623623
}
624624

625625
#[test]
626-
#[ignore]
626+
#[ignore = "slow. TODO: Introduce a slow test suite."]
627627
fn test_variety_from_lex_gb() {
628-
unimplemented!("Currently super slow");
629628
let ZZX = DensePolyRing::new(BigIntRing::RING, "X");
630629
let [f] = ZZX.with_wrapped_indeterminate(|X| [X - 1]);
631630
let QQ = NumberField::new(ZZX, &f);

src/computation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ where
217217
}
218218
} else {
219219
let mid = (from + to) / 2;
220-
controller.join(
220+
let _ = controller.join(
221221
move |controller| join_many_internal(controller, executor, tasks, from, mid, batch_tasks),
222222
move |controller| join_many_internal(controller, executor, tasks, mid, to, batch_tasks),
223223
);
@@ -240,7 +240,7 @@ where
240240
self.executor.finished.store(true, Ordering::Relaxed);
241241
self.executor.abort.store(Some(Box::new(abort)), Ordering::AcqRel);
242242
};
243-
self.controller.join(
243+
let _ = self.controller.join(
244244
|controller| {
245245
if self.executor.finished.load(Ordering::Relaxed) {
246246
return;

src/rings/approx_real/float.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::f64;
2-
use std::f64::EPSILON;
32

43
use crate::algorithms::convolution::KaratsubaHint;
54
use crate::algorithms::matmul::StrassenHint;
@@ -61,7 +60,7 @@ impl Real64Base {
6160
rhs: <Self as RingBase>::Element,
6261
precision: u64,
6362
) -> bool {
64-
let scaled_precision = precision as f64 * EPSILON;
63+
let scaled_precision = precision as f64 * f64::EPSILON;
6564
if self.is_absolute_approx_eq(lhs, self.zero(), scaled_precision) {
6665
self.is_absolute_approx_eq(rhs, self.zero(), scaled_precision)
6766
} else {

src/rings/direct_power.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,13 @@ impl<R: RingStore, const N: usize> RingBase for DirectPowerRingBase<R, N> {
138138
_env: EnvBindingStrength,
139139
) -> std::fmt::Result {
140140
write!(out, "(")?;
141-
for i in 0..N {
142-
self.base
143-
.get_ring()
144-
.dbg_within(&value[i], out, EnvBindingStrength::Weakest)?;
145-
if i + 1 != N {
141+
for (i, v) in value.iter().enumerate() {
142+
if i > 0 {
146143
write!(out, ", ")?;
147144
}
145+
self.base.get_ring().dbg_within(v, out, EnvBindingStrength::Weakest)?;
148146
}
149-
write!(out, ")")?;
150-
return Ok(());
147+
write!(out, ")")
151148
}
152149

153150
fn square(&self, value: &mut Self::Element) {
@@ -354,9 +351,9 @@ where
354351
}
355352
}
356353

357-
impl<'a, 'b, R: RingStore, const N: usize> Copy for DirectPowerRingElCreator<'a, R, N> {}
354+
impl<'a, R: RingStore, const N: usize> Copy for DirectPowerRingElCreator<'a, R, N> {}
358355

359-
impl<'a, 'b, R: RingStore, const N: usize> Clone for DirectPowerRingElCreator<'a, R, N> {
356+
impl<'a, R: RingStore, const N: usize> Clone for DirectPowerRingElCreator<'a, R, N> {
360357
fn clone(&self) -> Self { *self }
361358
}
362359

src/rings/extension/extension_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ where
234234
base_ring: self.base_ring(),
235235
data,
236236
});
237-
if was_sparse.is_err() {
237+
if was_sparse.is_none() {
238238
for i in (self.rank()..(2 * self.rank())).rev() {
239239
for j in 0..self.x_pow_rank.len() {
240240
let add = self.base_ring.mul_ref(self.x_pow_rank.at(j), &data[i]);

src/rings/multivariate/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub trait MultivariatePolyRing: RingExtension {
7272
/// every `i` in `0..self.indeterminate_count()`.
7373
fn expand_monomial_to(&self, m: &Self::Monomial, out: &mut [usize]) {
7474
assert_eq!(out.len(), self.indeterminate_count());
75-
for i in 0..self.indeterminate_count() {
76-
out[i] = self.exponent_at(m, i)
75+
for (i, out) in out.iter_mut().enumerate() {
76+
*out = self.exponent_at(m, i);
7777
}
7878
}
7979

@@ -158,8 +158,8 @@ pub trait MultivariatePolyRing: RingExtension {
158158
fn appearing_indeterminates(&self, f: &Self::Element) -> Vec<(usize, usize)> {
159159
let mut result = (0..self.indeterminate_count()).map(|_| 0).collect::<Vec<_>>();
160160
for (_, m) in self.terms(f) {
161-
for i in 0..self.indeterminate_count() {
162-
result[i] = max(result[i], self.exponent_at(m, i));
161+
for (i, result) in result.iter_mut().enumerate() {
162+
*result = max(*result, self.exponent_at(m, i));
163163
}
164164
}
165165
return result.into_iter().enumerate().filter(|(_, e)| *e > 0).collect();

src/seq/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<
110110
pub struct VectorFnMap<V: VectorFn<T>, T, U, F: Fn(T) -> U> {
111111
base: V,
112112
mapping_fn: F,
113-
elements: PhantomData<(fn(T), fn() -> U)>,
113+
elements: PhantomData<(T, U)>,
114114
}
115115

116116
impl<V: Clone + VectorFn<T>, T, U, F: Clone + Fn(T) -> U> Clone for VectorFnMap<V, T, U, F> {

src/seq/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub mod sparse;
6161
/// ```
6262
pub trait VectorView<T: ?Sized> {
6363
fn len(&self) -> usize;
64+
fn is_empty(&self) -> bool { self.len() == 0 }
6465
fn at(&self, i: usize) -> &T;
6566

6667
/// Returns a refernce to the `i`-th entry of the vector view, causing
@@ -70,16 +71,16 @@ pub trait VectorView<T: ?Sized> {
7071
///
7172
/// Same as for [`slice::get_unchecked()`]. More concretely, calling this method with an
7273
/// out-of-bounds index is undefined behavior even if the resulting reference is not used.
73-
unsafe fn at_unchecked<'a>(&self, i: usize) -> &T { self.at(i) }
74+
unsafe fn at_unchecked(&self, i: usize) -> &T { self.at(i) }
7475

7576
/// Calls `op` with `self` if this vector view supports sparse access.
7677
/// Otherwise, `()` is returned.
7778
///
7879
/// This is basically a workaround that enables users to specialize on
7980
/// `V: VectorViewSparse`, even though specialization currently does not support
8081
/// this.
81-
fn specialize_sparse<'a, Op: SparseVectorViewOperation<T>>(&'a self, _op: Op) -> Result<Op::Output<'a>, ()> {
82-
Err(())
82+
fn specialize_sparse<'a, Op: SparseVectorViewOperation<T>>(&'a self, _op: Op) -> Option<Op::Output<'a>> {
83+
None
8384
}
8485

8586
/// Returns an iterator over all elements in this vector.
@@ -341,7 +342,7 @@ impl<T: ?Sized, V: ?Sized + VectorView<T>> VectorView<T> for Box<V> {
341342

342343
unsafe fn at_unchecked(&self, i: usize) -> &T { unsafe { (**self).at_unchecked(i) } }
343344

344-
fn specialize_sparse<'a, Op: SparseVectorViewOperation<T>>(&'a self, op: Op) -> Result<Op::Output<'a>, ()> {
345+
fn specialize_sparse<'a, Op: SparseVectorViewOperation<T>>(&'a self, op: Op) -> Option<Op::Output<'a>> {
345346
(**self).specialize_sparse(op)
346347
}
347348

@@ -383,7 +384,7 @@ impl<T: ?Sized, V: ?Sized + VectorView<T>> VectorView<T> for &V {
383384

384385
unsafe fn at_unchecked(&self, i: usize) -> &T { unsafe { (**self).at_unchecked(i) } }
385386

386-
fn specialize_sparse<'b, Op: SparseVectorViewOperation<T>>(&'b self, op: Op) -> Result<Op::Output<'b>, ()> {
387+
fn specialize_sparse<'b, Op: SparseVectorViewOperation<T>>(&'b self, op: Op) -> Option<Op::Output<'b>> {
387388
(**self).specialize_sparse(op)
388389
}
389390

@@ -412,7 +413,7 @@ impl<T: ?Sized, V: ?Sized + VectorView<T>> VectorView<T> for &mut V {
412413

413414
unsafe fn at_unchecked(&self, i: usize) -> &T { unsafe { (**self).at_unchecked(i) } }
414415

415-
fn specialize_sparse<'b, Op: SparseVectorViewOperation<T>>(&'b self, op: Op) -> Result<Op::Output<'b>, ()> {
416+
fn specialize_sparse<'b, Op: SparseVectorViewOperation<T>>(&'b self, op: Op) -> Option<Op::Output<'b>> {
416417
(**self).specialize_sparse(op)
417418
}
418419

@@ -488,7 +489,7 @@ pub trait VectorViewMut<T: ?Sized>: VectorView<T> {
488489
///
489490
/// Same as for [`slice::get_unchecked_mut()`]. More concretely, calling this method with an
490491
/// out-of-bounds index is undefined behavior even if the resulting reference is not used.
491-
unsafe fn at_unchecked_mut<'a>(&mut self, i: usize) -> &mut T { self.at_mut(i) }
492+
unsafe fn at_unchecked_mut(&mut self, i: usize) -> &mut T { self.at_mut(i) }
492493
}
493494

494495
/// A trait for [`VectorViewMut`]s that support swapping of two elements.
@@ -533,6 +534,7 @@ pub trait SwappableVectorViewMut<T: ?Sized>: VectorViewMut<T> {
533534
/// ```
534535
pub trait VectorFn<T> {
535536
fn len(&self) -> usize;
537+
fn is_empty(&self) -> bool { self.len() == 0 }
536538
fn at(&self, i: usize) -> T;
537539

538540
/// Produces an iterator over the elements of this [`VectorFn`].

0 commit comments

Comments
 (0)