Skip to content

Commit

Permalink
Fix new Clippy lints (#1511)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Oct 15, 2024
1 parent f5185d9 commit 695fc9a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions rand_core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ pub trait CryptoBlockRng: BlockRngCore {}
#[cfg_attr(
feature = "serde",
serde(
bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>"
bound = "for<'x> R: Serialize + Deserialize<'x>, for<'x> R::Results: Serialize + Deserialize<'x>"
)
)]
pub struct BlockRng<R: BlockRngCore + ?Sized> {
pub struct BlockRng<R: BlockRngCore> {
results: R::Results,
index: usize,
/// The *core* part of the RNG, implementing the `generate` function.
Expand Down
5 changes: 1 addition & 4 deletions rand_distr/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ pub(crate) fn log_gamma<F: Float>(x: F) -> F {
/// * `pdf`: the probability density function
/// * `zero_case`: manual sampling from the tail when we chose the
/// bottom box (i.e. i == 0)

// the perf improvement (25-50%) is definitely worth the extra code
// size from force-inlining.
#[inline(always)]
#[inline(always)] // Forced inlining improves the perf by 25-50%
pub(crate) fn ziggurat<R: Rng + ?Sized, P, Z>(
rng: &mut R,
symmetric: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/distr/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub trait Distribution<T> {
}
}

impl<'a, T, D: Distribution<T> + ?Sized> Distribution<T> for &'a D {
impl<T, D: Distribution<T> + ?Sized> Distribution<T> for &D {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> T {
(*self).sample(rng)
}
Expand Down
2 changes: 1 addition & 1 deletion src/distr/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl std::error::Error for EmptySlice {}
/// Note: the `String` is potentially left with excess capacity; optionally the
/// user may call `string.shrink_to_fit()` afterwards.
#[cfg(feature = "alloc")]
impl<'a> super::DistString for Slice<'a, char> {
impl super::DistString for Slice<'_, char> {
fn append_string<R: crate::Rng + ?Sized>(&self, rng: &mut R, string: &mut String, len: usize) {
// Get the max char length to minimize extra space.
// Limit this check to avoid searching for long slice.
Expand Down
2 changes: 1 addition & 1 deletion src/distr/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ where
self
}
}
impl<'a, Borrowed> SampleBorrow<Borrowed> for &'a Borrowed
impl<Borrowed> SampleBorrow<Borrowed> for &Borrowed
where
Borrowed: SampleUniform,
{
Expand Down
6 changes: 3 additions & 3 deletions src/distr/weighted_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub struct WeightedIndexIter<'a, X: SampleUniform + PartialOrd> {
index: usize,
}

impl<'a, X> Debug for WeightedIndexIter<'a, X>
impl<X> Debug for WeightedIndexIter<'_, X>
where
X: SampleUniform + PartialOrd + Debug,
X::Sampler: Debug,
Expand All @@ -269,7 +269,7 @@ where
}
}

impl<'a, X> Clone for WeightedIndexIter<'a, X>
impl<X> Clone for WeightedIndexIter<'_, X>
where
X: SampleUniform + PartialOrd,
{
Expand All @@ -281,7 +281,7 @@ where
}
}

impl<'a, X> Iterator for WeightedIndexIter<'a, X>
impl<X> Iterator for WeightedIndexIter<'_, X>
where
X: for<'b> core::ops::SubAssign<&'b X> + SampleUniform + PartialOrd + Clone,
{
Expand Down
4 changes: 2 additions & 2 deletions src/seq/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub enum IndexVecIter<'a> {
U64(slice::Iter<'a, u64>),
}

impl<'a> Iterator for IndexVecIter<'a> {
impl Iterator for IndexVecIter<'_> {
type Item = usize;

#[inline]
Expand All @@ -176,7 +176,7 @@ impl<'a> Iterator for IndexVecIter<'a> {
}
}

impl<'a> ExactSizeIterator for IndexVecIter<'a> {}
impl ExactSizeIterator for IndexVecIter<'_> {}

/// Return type of `IndexVec::into_iter`.
#[derive(Clone, Debug)]
Expand Down

0 comments on commit 695fc9a

Please sign in to comment.