Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct SplitWriter<'a> {
dev_null: bool,
}

impl<'a> Drop for SplitWriter<'a> {
impl Drop for SplitWriter<'_> {
fn drop(&mut self) {
if self.options.elide_empty_files && self.size == 0 {
let file_name = self.options.split_name.get(self.counter);
Expand All @@ -206,7 +206,7 @@ impl<'a> Drop for SplitWriter<'a> {
}
}

impl<'a> SplitWriter<'a> {
impl SplitWriter<'_> {
fn new(options: &CsplitOptions) -> SplitWriter {
SplitWriter {
options,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cut/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> ExactMatcher<'a> {
}
}

impl<'a> Matcher for ExactMatcher<'a> {
impl Matcher for ExactMatcher<'_> {
fn next_match(&self, haystack: &[u8]) -> Option<(usize, usize)> {
let mut pos = 0usize;
loop {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cut/src/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'a, 'b, M: Matcher> Searcher<'a, 'b, M> {
// Iterate over field delimiters
// Returns (first, last) positions of each sequence, where `haystack[first..last]`
// corresponds to the delimiter.
impl<'a, 'b, M: Matcher> Iterator for Searcher<'a, 'b, M> {
impl<M: Matcher> Iterator for Searcher<'_, '_, M> {
type Item = (usize, usize);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ enum Iso8601Format {
Ns,
}

impl<'a> From<&'a str> for Iso8601Format {
impl From<&str> for Iso8601Format {
fn from(s: &str) -> Self {
match s {
HOURS => Self::Hours,
Expand All @@ -123,7 +123,7 @@ enum Rfc3339Format {
Ns,
}

impl<'a> From<&'a str> for Rfc3339Format {
impl From<&str> for Rfc3339Format {
fn from(s: &str) -> Self {
match s {
DATE => Self::Date,
Expand Down
6 changes: 3 additions & 3 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ fn make_linux_iflags(iflags: &IFlags) -> Option<libc::c_int> {
}
}

impl<'a> Read for Input<'a> {
impl Read for Input<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let mut base_idx = 0;
let target_len = buf.len();
Expand All @@ -447,7 +447,7 @@ impl<'a> Read for Input<'a> {
}
}

impl<'a> Input<'a> {
impl Input<'_> {
/// Discard the system file cache for the given portion of the input.
///
/// `offset` and `len` specify a contiguous portion of the input.
Expand Down Expand Up @@ -928,7 +928,7 @@ enum BlockWriter<'a> {
Unbuffered(Output<'a>),
}

impl<'a> BlockWriter<'a> {
impl BlockWriter<'_> {
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
match self {
Self::Unbuffered(o) => o.discard_cache(offset, len),
Expand Down
3 changes: 2 additions & 1 deletion src/uu/dd/src/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
/// Functions for formatting a number as a magnitude and a unit suffix.

//! Functions for formatting a number as a magnitude and a unit suffix.

/// The first ten powers of 1024.
const IEC_BASES: [u128; 10] = [
Expand Down
2 changes: 0 additions & 2 deletions src/uu/df/src/df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ fn is_best(previous: &[MountInfo], mi: &MountInfo) -> bool {
///
/// Finally, if there are duplicate entries, the one with the shorter
/// path is kept.

fn filter_mount_list(vmi: Vec<MountInfo>, opt: &Options) -> Vec<MountInfo> {
let mut result = vec![];
for mi in vmi {
Expand All @@ -331,7 +330,6 @@ fn filter_mount_list(vmi: Vec<MountInfo>, opt: &Options) -> Vec<MountInfo> {
///
/// `opt` excludes certain filesystems from consideration and allows for the synchronization of filesystems before running; see
/// [`Options`] for more information.

fn get_all_filesystems(opt: &Options) -> UResult<Vec<Filesystem>> {
// Run a sync call before any operation if so instructed.
if opt.sync {
Expand Down
5 changes: 2 additions & 3 deletions src/uu/env/src/string_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ impl<'a> StringParser<'a> {
}

pub fn peek_chunk(&self) -> Option<Chunk<'a>> {
return self
.get_chunk_with_length_at(self.pointer)
self.get_chunk_with_length_at(self.pointer)
.ok()
.map(|(chunk, _)| chunk);
.map(|(chunk, _)| chunk)
}

pub fn consume_chunk(&mut self) -> Result<Chunk<'a>, Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/env/src/variable_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct VariableParser<'a, 'b> {
pub parser: &'b mut StringParser<'a>,
}

impl<'a, 'b> VariableParser<'a, 'b> {
impl<'a> VariableParser<'a, '_> {
fn get_current_char(&self) -> Option<char> {
self.parser.peek().ok()
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/fmt/src/linebreak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct BreakArgs<'a> {
ostream: &'a mut BufWriter<Stdout>,
}

impl<'a> BreakArgs<'a> {
impl BreakArgs<'_> {
fn compute_width(&self, winfo: &WordInfo, posn: usize, fresh: bool) -> usize {
if fresh {
0
Expand Down
12 changes: 6 additions & 6 deletions src/uu/fmt/src/parasplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct FileLines<'a> {
lines: Lines<&'a mut FileOrStdReader>,
}

impl<'a> FileLines<'a> {
impl FileLines<'_> {
fn new<'b>(opts: &'b FmtOptions, lines: Lines<&'b mut FileOrStdReader>) -> FileLines<'b> {
FileLines { opts, lines }
}
Expand Down Expand Up @@ -144,7 +144,7 @@ impl<'a> FileLines<'a> {
}
}

impl<'a> Iterator for FileLines<'a> {
impl Iterator for FileLines<'_> {
type Item = Line;

fn next(&mut self) -> Option<Line> {
Expand Down Expand Up @@ -232,7 +232,7 @@ pub struct ParagraphStream<'a> {
opts: &'a FmtOptions,
}

impl<'a> ParagraphStream<'a> {
impl ParagraphStream<'_> {
pub fn new<'b>(opts: &'b FmtOptions, reader: &'b mut FileOrStdReader) -> ParagraphStream<'b> {
let lines = FileLines::new(opts, reader.lines()).peekable();
// at the beginning of the file, we might find mail headers
Expand Down Expand Up @@ -273,7 +273,7 @@ impl<'a> ParagraphStream<'a> {
}
}

impl<'a> Iterator for ParagraphStream<'a> {
impl Iterator for ParagraphStream<'_> {
type Item = Result<Paragraph, String>;

#[allow(clippy::cognitive_complexity)]
Expand Down Expand Up @@ -491,7 +491,7 @@ struct WordSplit<'a> {
prev_punct: bool,
}

impl<'a> WordSplit<'a> {
impl WordSplit<'_> {
fn analyze_tabs(&self, string: &str) -> (Option<usize>, usize, Option<usize>) {
// given a string, determine (length before tab) and (printed length after first tab)
// if there are no tabs, beforetab = -1 and aftertab is the printed length
Expand All @@ -517,7 +517,7 @@ impl<'a> WordSplit<'a> {
}
}

impl<'a> WordSplit<'a> {
impl WordSplit<'_> {
fn new<'b>(opts: &'b FmtOptions, string: &'b str) -> WordSplit<'b> {
// wordsplits *must* start at a non-whitespace character
let trim_string = string.trim_start();
Expand Down
2 changes: 1 addition & 1 deletion src/uu/join/src/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct MultiByteSep<'a> {
finder: Finder<'a>,
}

impl<'a> Separator for MultiByteSep<'a> {
impl Separator for MultiByteSep<'_> {
fn field_ranges(&self, haystack: &[u8], len_guess: usize) -> Vec<(usize, usize)> {
let mut field_ranges = Vec::with_capacity(len_guess);
let mut last_end = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/uu/od/src/inputdecoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
byte_order: ByteOrder,
}

impl<'a, I> InputDecoder<'a, I> {
impl<I> InputDecoder<'_, I> {
/// Creates a new `InputDecoder` with an allocated buffer of `normal_length` + `peek_length` bytes.
/// `byte_order` determines how to read multibyte formats from the buffer.
pub fn new(
Expand All @@ -55,7 +55,7 @@ impl<'a, I> InputDecoder<'a, I> {
}
}

impl<'a, I> InputDecoder<'a, I>
impl<I> InputDecoder<'_, I>
where
I: PeekRead,
{
Expand All @@ -81,7 +81,7 @@ where
}
}

impl<'a, I> HasError for InputDecoder<'a, I>
impl<I> HasError for InputDecoder<'_, I>
where
I: HasError,
{
Expand All @@ -103,7 +103,7 @@ pub struct MemoryDecoder<'a> {
byte_order: ByteOrder,
}

impl<'a> MemoryDecoder<'a> {
impl MemoryDecoder<'_> {
/// Set a part of the internal buffer to zero.
/// access to the whole buffer is possible, not just to the valid data.
pub fn zero_out_buffer(&mut self, start: usize, end: usize) {
Expand Down
6 changes: 3 additions & 3 deletions src/uu/od/src/multifilereader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub trait HasError {
fn has_error(&self) -> bool;
}

impl<'b> MultifileReader<'b> {
impl MultifileReader<'_> {
pub fn new(fnames: Vec<InputSource>) -> MultifileReader {
let mut mf = MultifileReader {
ni: fnames,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<'b> MultifileReader<'b> {
}
}

impl<'b> io::Read for MultifileReader<'b> {
impl io::Read for MultifileReader<'_> {
// Fill buf with bytes read from the list of files
// Returns Ok(<number of bytes read>)
// Handles io errors itself, thus always returns OK
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<'b> io::Read for MultifileReader<'b> {
}
}

impl<'b> HasError for MultifileReader<'b> {
impl HasError for MultifileReader<'_> {
fn has_error(&self) -> bool {
self.any_err
}
Expand Down
14 changes: 10 additions & 4 deletions src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ impl<'a> Shufable for Vec<&'a [u8]> {
// this is safe.
(**self).choose(rng).unwrap()
}
type PartialShuffleIterator<'b> = std::iter::Copied<std::slice::Iter<'b, &'a [u8]>> where Self: 'b;
type PartialShuffleIterator<'b>
= std::iter::Copied<std::slice::Iter<'b, &'a [u8]>>
where
Self: 'b;
fn partial_shuffle<'b>(
&'b mut self,
rng: &'b mut WrappedRng,
Expand All @@ -298,7 +301,10 @@ impl Shufable for RangeInclusive<usize> {
fn choose(&self, rng: &mut WrappedRng) -> usize {
rng.gen_range(self.clone())
}
type PartialShuffleIterator<'b> = NonrepeatingIterator<'b> where Self: 'b;
type PartialShuffleIterator<'b>
= NonrepeatingIterator<'b>
where
Self: 'b;
fn partial_shuffle<'b>(
&'b mut self,
rng: &'b mut WrappedRng,
Expand Down Expand Up @@ -374,7 +380,7 @@ impl<'a> NonrepeatingIterator<'a> {
}
}

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

fn next(&mut self) -> Option<usize> {
Expand All @@ -401,7 +407,7 @@ trait Writable {
fn write_all_to(&self, output: &mut impl Write) -> Result<(), Error>;
}

impl<'a> Writable for &'a [u8] {
impl Writable for &[u8] {
fn write_all_to(&self, output: &mut impl Write) -> Result<(), Error> {
output.write_all(self)
}
Expand Down
4 changes: 2 additions & 2 deletions src/uu/sort/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub struct FileMerger<'a> {
reader_join_handle: JoinHandle<UResult<()>>,
}

impl<'a> FileMerger<'a> {
impl FileMerger<'_> {
/// Write the merged contents to the output file.
pub fn write_all(self, settings: &GlobalSettings, output: Output) -> UResult<()> {
let mut out = output.into_write();
Expand Down Expand Up @@ -341,7 +341,7 @@ struct FileComparator<'a> {
settings: &'a GlobalSettings,
}

impl<'a> Compare<MergeableFile> for FileComparator<'a> {
impl Compare<MergeableFile> for FileComparator<'_> {
fn compare(&self, a: &MergeableFile, b: &MergeableFile) -> Ordering {
let mut cmp = compare_by(
&a.current_chunk.lines()[a.line_idx],
Expand Down
2 changes: 1 addition & 1 deletion src/uu/split/src/filenames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<'a> FilenameIterator<'a> {
}
}

impl<'a> Iterator for FilenameIterator<'a> {
impl Iterator for FilenameIterator<'_> {
type Item = String;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 3 additions & 3 deletions src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ impl<'a> ByteChunkWriter<'a> {
}
}

impl<'a> Write for ByteChunkWriter<'a> {
impl Write for ByteChunkWriter<'_> {
/// Implements `--bytes=SIZE`
fn write(&mut self, mut buf: &[u8]) -> std::io::Result<usize> {
// If the length of `buf` exceeds the number of bytes remaining
Expand Down Expand Up @@ -872,7 +872,7 @@ impl<'a> LineChunkWriter<'a> {
}
}

impl<'a> Write for LineChunkWriter<'a> {
impl Write for LineChunkWriter<'_> {
/// Implements `--lines=NUMBER`
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
// If the number of lines in `buf` exceeds the number of lines
Expand Down Expand Up @@ -978,7 +978,7 @@ impl<'a> LineBytesChunkWriter<'a> {
}
}

impl<'a> Write for LineBytesChunkWriter<'a> {
impl Write for LineBytesChunkWriter<'_> {
/// Write as many lines to a chunk as possible without
/// exceeding the byte limit. If a single line has more bytes
/// than the limit, then fill an entire single chunk with those
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tail/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> ReverseChunks<'a> {
}
}

impl<'a> Iterator for ReverseChunks<'a> {
impl Iterator for ReverseChunks<'_> {
type Item = Vec<u8>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
1 change: 0 additions & 1 deletion src/uu/timeout/src/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ fn preserve_signal_info(signal: libc::c_int) -> libc::c_int {
}

/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes.

fn timeout(
cmd: &[String],
duration: Duration,
Expand Down
4 changes: 2 additions & 2 deletions src/uu/wc/src/utf8/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum BufReadDecoderError<'a> {
Io(io::Error),
}

impl<'a> fmt::Display for BufReadDecoderError<'a> {
impl fmt::Display for BufReadDecoderError<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BufReadDecoderError::InvalidByteSequence(bytes) => {
Expand All @@ -38,7 +38,7 @@ impl<'a> fmt::Display for BufReadDecoderError<'a> {
}
}

impl<'a> Error for BufReadDecoderError<'a> {
impl Error for BufReadDecoderError<'_> {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match *self {
BufReadDecoderError::InvalidByteSequence(_) => None,
Expand Down
Loading
Loading