mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 06:42:42 +00:00
uucore: Fix a clippy warning
The following explicit lifetimes could be elided: 'a
This commit is contained in:
parent
4d3902426a
commit
41a3695b3f
18 changed files with 37 additions and 37 deletions
|
@ -197,7 +197,7 @@ struct SplitWriter<'a> {
|
||||||
dev_null: bool,
|
dev_null: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for SplitWriter<'a> {
|
impl Drop for SplitWriter<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.options.elide_empty_files && self.size == 0 {
|
if self.options.elide_empty_files && self.size == 0 {
|
||||||
let file_name = self.options.split_name.get(self.counter);
|
let file_name = self.options.split_name.get(self.counter);
|
||||||
|
@ -206,7 +206,7 @@ impl<'a> Drop for SplitWriter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SplitWriter<'a> {
|
impl SplitWriter<'_> {
|
||||||
fn new(options: &CsplitOptions) -> SplitWriter {
|
fn new(options: &CsplitOptions) -> SplitWriter {
|
||||||
SplitWriter {
|
SplitWriter {
|
||||||
options,
|
options,
|
||||||
|
|
|
@ -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)> {
|
fn next_match(&self, haystack: &[u8]) -> Option<(usize, usize)> {
|
||||||
let mut pos = 0usize;
|
let mut pos = 0usize;
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl<'a, 'b, M: Matcher> Searcher<'a, 'b, M> {
|
||||||
// Iterate over field delimiters
|
// Iterate over field delimiters
|
||||||
// Returns (first, last) positions of each sequence, where `haystack[first..last]`
|
// Returns (first, last) positions of each sequence, where `haystack[first..last]`
|
||||||
// corresponds to the delimiter.
|
// 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);
|
type Item = (usize, usize);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
|
|
@ -103,7 +103,7 @@ enum Iso8601Format {
|
||||||
Ns,
|
Ns,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a str> for Iso8601Format {
|
impl From<&str> for Iso8601Format {
|
||||||
fn from(s: &str) -> Self {
|
fn from(s: &str) -> Self {
|
||||||
match s {
|
match s {
|
||||||
HOURS => Self::Hours,
|
HOURS => Self::Hours,
|
||||||
|
@ -123,7 +123,7 @@ enum Rfc3339Format {
|
||||||
Ns,
|
Ns,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a str> for Rfc3339Format {
|
impl From<&str> for Rfc3339Format {
|
||||||
fn from(s: &str) -> Self {
|
fn from(s: &str) -> Self {
|
||||||
match s {
|
match s {
|
||||||
DATE => Self::Date,
|
DATE => Self::Date,
|
||||||
|
|
|
@ -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> {
|
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
let mut base_idx = 0;
|
let mut base_idx = 0;
|
||||||
let target_len = buf.len();
|
let target_len = buf.len();
|
||||||
|
@ -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.
|
/// Discard the system file cache for the given portion of the input.
|
||||||
///
|
///
|
||||||
/// `offset` and `len` specify a contiguous portion of the input.
|
/// `offset` and `len` specify a contiguous portion of the input.
|
||||||
|
@ -928,7 +928,7 @@ enum BlockWriter<'a> {
|
||||||
Unbuffered(Output<'a>),
|
Unbuffered(Output<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BlockWriter<'a> {
|
impl BlockWriter<'_> {
|
||||||
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
|
fn discard_cache(&self, offset: libc::off_t, len: libc::off_t) {
|
||||||
match self {
|
match self {
|
||||||
Self::Unbuffered(o) => o.discard_cache(offset, len),
|
Self::Unbuffered(o) => o.discard_cache(offset, len),
|
||||||
|
|
2
src/uu/env/src/variable_parser.rs
vendored
2
src/uu/env/src/variable_parser.rs
vendored
|
@ -11,7 +11,7 @@ pub struct VariableParser<'a, 'b> {
|
||||||
pub parser: &'b mut StringParser<'a>,
|
pub parser: &'b mut StringParser<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> VariableParser<'a, 'b> {
|
impl<'a> VariableParser<'a, '_> {
|
||||||
fn get_current_char(&self) -> Option<char> {
|
fn get_current_char(&self) -> Option<char> {
|
||||||
self.parser.peek().ok()
|
self.parser.peek().ok()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct BreakArgs<'a> {
|
||||||
ostream: &'a mut BufWriter<Stdout>,
|
ostream: &'a mut BufWriter<Stdout>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BreakArgs<'a> {
|
impl BreakArgs<'_> {
|
||||||
fn compute_width(&self, winfo: &WordInfo, posn: usize, fresh: bool) -> usize {
|
fn compute_width(&self, winfo: &WordInfo, posn: usize, fresh: bool) -> usize {
|
||||||
if fresh {
|
if fresh {
|
||||||
0
|
0
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub struct FileLines<'a> {
|
||||||
lines: Lines<&'a mut FileOrStdReader>,
|
lines: Lines<&'a mut FileOrStdReader>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileLines<'a> {
|
impl FileLines<'_> {
|
||||||
fn new<'b>(opts: &'b FmtOptions, lines: Lines<&'b mut FileOrStdReader>) -> FileLines<'b> {
|
fn new<'b>(opts: &'b FmtOptions, lines: Lines<&'b mut FileOrStdReader>) -> FileLines<'b> {
|
||||||
FileLines { opts, lines }
|
FileLines { opts, lines }
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ impl<'a> FileLines<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for FileLines<'a> {
|
impl Iterator for FileLines<'_> {
|
||||||
type Item = Line;
|
type Item = Line;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Line> {
|
fn next(&mut self) -> Option<Line> {
|
||||||
|
@ -232,7 +232,7 @@ pub struct ParagraphStream<'a> {
|
||||||
opts: &'a FmtOptions,
|
opts: &'a FmtOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ParagraphStream<'a> {
|
impl ParagraphStream<'_> {
|
||||||
pub fn new<'b>(opts: &'b FmtOptions, reader: &'b mut FileOrStdReader) -> ParagraphStream<'b> {
|
pub fn new<'b>(opts: &'b FmtOptions, reader: &'b mut FileOrStdReader) -> ParagraphStream<'b> {
|
||||||
let lines = FileLines::new(opts, reader.lines()).peekable();
|
let lines = FileLines::new(opts, reader.lines()).peekable();
|
||||||
// at the beginning of the file, we might find mail headers
|
// at the beginning of the file, we might find mail headers
|
||||||
|
@ -273,7 +273,7 @@ impl<'a> ParagraphStream<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for ParagraphStream<'a> {
|
impl Iterator for ParagraphStream<'_> {
|
||||||
type Item = Result<Paragraph, String>;
|
type Item = Result<Paragraph, String>;
|
||||||
|
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
|
@ -491,7 +491,7 @@ struct WordSplit<'a> {
|
||||||
prev_punct: bool,
|
prev_punct: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WordSplit<'a> {
|
impl WordSplit<'_> {
|
||||||
fn analyze_tabs(&self, string: &str) -> (Option<usize>, usize, Option<usize>) {
|
fn analyze_tabs(&self, string: &str) -> (Option<usize>, usize, Option<usize>) {
|
||||||
// given a string, determine (length before tab) and (printed length after first tab)
|
// 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
|
// if there are no tabs, beforetab = -1 and aftertab is the printed length
|
||||||
|
@ -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> {
|
fn new<'b>(opts: &'b FmtOptions, string: &'b str) -> WordSplit<'b> {
|
||||||
// wordsplits *must* start at a non-whitespace character
|
// wordsplits *must* start at a non-whitespace character
|
||||||
let trim_string = string.trim_start();
|
let trim_string = string.trim_start();
|
||||||
|
|
|
@ -109,7 +109,7 @@ struct MultiByteSep<'a> {
|
||||||
finder: Finder<'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)> {
|
fn field_ranges(&self, haystack: &[u8], len_guess: usize) -> Vec<(usize, usize)> {
|
||||||
let mut field_ranges = Vec::with_capacity(len_guess);
|
let mut field_ranges = Vec::with_capacity(len_guess);
|
||||||
let mut last_end = 0;
|
let mut last_end = 0;
|
||||||
|
|
|
@ -33,7 +33,7 @@ where
|
||||||
byte_order: ByteOrder,
|
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.
|
/// 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.
|
/// `byte_order` determines how to read multibyte formats from the buffer.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -55,7 +55,7 @@ impl<'a, I> InputDecoder<'a, I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, I> InputDecoder<'a, I>
|
impl<I> InputDecoder<'_, I>
|
||||||
where
|
where
|
||||||
I: PeekRead,
|
I: PeekRead,
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, I> HasError for InputDecoder<'a, I>
|
impl<I> HasError for InputDecoder<'_, I>
|
||||||
where
|
where
|
||||||
I: HasError,
|
I: HasError,
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ pub struct MemoryDecoder<'a> {
|
||||||
byte_order: ByteOrder,
|
byte_order: ByteOrder,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MemoryDecoder<'a> {
|
impl MemoryDecoder<'_> {
|
||||||
/// Set a part of the internal buffer to zero.
|
/// Set a part of the internal buffer to zero.
|
||||||
/// access to the whole buffer is possible, not just to the valid data.
|
/// access to the whole buffer is possible, not just to the valid data.
|
||||||
pub fn zero_out_buffer(&mut self, start: usize, end: usize) {
|
pub fn zero_out_buffer(&mut self, start: usize, end: usize) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub trait HasError {
|
||||||
fn has_error(&self) -> bool;
|
fn has_error(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> MultifileReader<'b> {
|
impl MultifileReader<'_> {
|
||||||
pub fn new(fnames: Vec<InputSource>) -> MultifileReader {
|
pub fn new(fnames: Vec<InputSource>) -> MultifileReader {
|
||||||
let mut mf = MultifileReader {
|
let mut mf = MultifileReader {
|
||||||
ni: fnames,
|
ni: fnames,
|
||||||
|
@ -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
|
// Fill buf with bytes read from the list of files
|
||||||
// Returns Ok(<number of bytes read>)
|
// Returns Ok(<number of bytes read>)
|
||||||
// Handles io errors itself, thus always returns OK
|
// Handles io errors itself, thus always returns OK
|
||||||
|
@ -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 {
|
fn has_error(&self) -> bool {
|
||||||
self.any_err
|
self.any_err
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,7 @@ impl<'a> NonrepeatingIterator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for NonrepeatingIterator<'a> {
|
impl Iterator for NonrepeatingIterator<'_> {
|
||||||
type Item = usize;
|
type Item = usize;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<usize> {
|
fn next(&mut self) -> Option<usize> {
|
||||||
|
@ -407,7 +407,7 @@ trait Writable {
|
||||||
fn write_all_to(&self, output: &mut impl Write) -> Result<(), Error>;
|
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> {
|
fn write_all_to(&self, output: &mut impl Write) -> Result<(), Error> {
|
||||||
output.write_all(self)
|
output.write_all(self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ pub struct FileMerger<'a> {
|
||||||
reader_join_handle: JoinHandle<UResult<()>>,
|
reader_join_handle: JoinHandle<UResult<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileMerger<'a> {
|
impl FileMerger<'_> {
|
||||||
/// Write the merged contents to the output file.
|
/// Write the merged contents to the output file.
|
||||||
pub fn write_all(self, settings: &GlobalSettings, output: Output) -> UResult<()> {
|
pub fn write_all(self, settings: &GlobalSettings, output: Output) -> UResult<()> {
|
||||||
let mut out = output.into_write();
|
let mut out = output.into_write();
|
||||||
|
@ -341,7 +341,7 @@ struct FileComparator<'a> {
|
||||||
settings: &'a GlobalSettings,
|
settings: &'a GlobalSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Compare<MergeableFile> for FileComparator<'a> {
|
impl Compare<MergeableFile> for FileComparator<'_> {
|
||||||
fn compare(&self, a: &MergeableFile, b: &MergeableFile) -> Ordering {
|
fn compare(&self, a: &MergeableFile, b: &MergeableFile) -> Ordering {
|
||||||
let mut cmp = compare_by(
|
let mut cmp = compare_by(
|
||||||
&a.current_chunk.lines()[a.line_idx],
|
&a.current_chunk.lines()[a.line_idx],
|
||||||
|
|
|
@ -341,7 +341,7 @@ impl<'a> FilenameIterator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for FilenameIterator<'a> {
|
impl Iterator for FilenameIterator<'_> {
|
||||||
type Item = String;
|
type Item = String;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
|
|
@ -748,7 +748,7 @@ impl<'a> ByteChunkWriter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Write for ByteChunkWriter<'a> {
|
impl Write for ByteChunkWriter<'_> {
|
||||||
/// Implements `--bytes=SIZE`
|
/// Implements `--bytes=SIZE`
|
||||||
fn write(&mut self, mut buf: &[u8]) -> std::io::Result<usize> {
|
fn write(&mut self, mut buf: &[u8]) -> std::io::Result<usize> {
|
||||||
// If the length of `buf` exceeds the number of bytes remaining
|
// If the length of `buf` exceeds the number of bytes remaining
|
||||||
|
@ -872,7 +872,7 @@ impl<'a> LineChunkWriter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Write for LineChunkWriter<'a> {
|
impl Write for LineChunkWriter<'_> {
|
||||||
/// Implements `--lines=NUMBER`
|
/// Implements `--lines=NUMBER`
|
||||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||||
// If the number of lines in `buf` exceeds the number of lines
|
// If the number of lines in `buf` exceeds the number of lines
|
||||||
|
@ -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
|
/// Write as many lines to a chunk as possible without
|
||||||
/// exceeding the byte limit. If a single line has more bytes
|
/// exceeding the byte limit. If a single line has more bytes
|
||||||
/// than the limit, then fill an entire single chunk with those
|
/// than the limit, then fill an entire single chunk with those
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<'a> ReverseChunks<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for ReverseChunks<'a> {
|
impl Iterator for ReverseChunks<'_> {
|
||||||
type Item = Vec<u8>;
|
type Item = Vec<u8>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub enum BufReadDecoderError<'a> {
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for BufReadDecoderError<'a> {
|
impl fmt::Display for BufReadDecoderError<'_> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
BufReadDecoderError::InvalidByteSequence(bytes) => {
|
BufReadDecoderError::InvalidByteSequence(bytes) => {
|
||||||
|
@ -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)> {
|
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||||
match *self {
|
match *self {
|
||||||
BufReadDecoderError::InvalidByteSequence(_) => None,
|
BufReadDecoderError::InvalidByteSequence(_) => None,
|
||||||
|
|
|
@ -403,7 +403,7 @@ impl<'a> DigestWriter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Write for DigestWriter<'a> {
|
impl Write for DigestWriter<'_> {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||||
self.digest.hash_update(buf);
|
self.digest.hash_update(buf);
|
||||||
|
|
Loading…
Reference in a new issue