diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 56e26568b..ae35469a7 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -243,17 +243,11 @@ trait Shufable { type Item: Writable; fn is_empty(&self) -> bool; fn choose(&self, rng: &mut WrappedRng) -> Self::Item; - // This type shouldn't even be known. However, because we want to support - // Rust 1.70, it is not possible to return "impl Iterator". - // TODO: When the MSRV is raised, rewrite this to return "impl Iterator". - type PartialShuffleIterator<'b>: Iterator - where - Self: 'b; fn partial_shuffle<'b>( &'b mut self, rng: &'b mut WrappedRng, amount: usize, - ) -> Self::PartialShuffleIterator<'b>; + ) -> impl Iterator; } impl<'a> Shufable for Vec<&'a [u8]> { @@ -267,15 +261,11 @@ impl<'a> Shufable for Vec<&'a [u8]> { // this is safe. (**self).choose(rng).unwrap() } - type PartialShuffleIterator<'b> - = std::iter::Copied> - where - Self: 'b; fn partial_shuffle<'b>( &'b mut self, rng: &'b mut WrappedRng, amount: usize, - ) -> Self::PartialShuffleIterator<'b> { + ) -> impl Iterator { // Note: "copied()" only copies the reference, not the entire [u8]. (**self).partial_shuffle(rng, amount).0.iter().copied() } @@ -289,12 +279,11 @@ impl<'a> Shufable for Vec<&'a OsStr> { fn choose(&self, rng: &mut WrappedRng) -> Self::Item { (**self).choose(rng).unwrap() } - type PartialShuffleIterator<'b> = std::iter::Copied> where Self: 'b; fn partial_shuffle<'b>( &'b mut self, rng: &'b mut WrappedRng, amount: usize, - ) -> Self::PartialShuffleIterator<'b> { + ) -> impl Iterator { (**self).partial_shuffle(rng, amount).0.iter().copied() } } @@ -307,15 +296,11 @@ impl Shufable for RangeInclusive { fn choose(&self, rng: &mut WrappedRng) -> usize { rng.random_range(self.clone()) } - type PartialShuffleIterator<'b> - = NonrepeatingIterator<'b> - where - Self: 'b; fn partial_shuffle<'b>( &'b mut self, rng: &'b mut WrappedRng, amount: usize, - ) -> Self::PartialShuffleIterator<'b> { + ) -> impl Iterator { NonrepeatingIterator::new(self.clone(), rng, amount) } }