Skip to content

Commit 49e2a48

Browse files
committed
appease latest Clippy warnings (1.89)
1 parent ba6b06a commit 49e2a48

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

crates/prettytty/src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ pub trait Scan: std::io::BufRead {
463463
/// connection upon invocation. For text tokens, it performs no further
464464
/// reads. That is, a text token always ends with the currently buffered
465465
/// data.
466-
fn read_token(&mut self) -> Result<Token>;
466+
fn read_token(&mut self) -> Result<Token<'_>>;
467467

468468
/// Read the next token as a control sequence.
469469
///
@@ -491,7 +491,7 @@ impl<S: Scan + ?Sized> Scan for &mut S {
491491
}
492492

493493
#[inline]
494-
fn read_token(&mut self) -> Result<Token> {
494+
fn read_token(&mut self) -> Result<Token<'_>> {
495495
(**self).read_token()
496496
}
497497
}
@@ -504,7 +504,7 @@ impl<S: Scan + ?Sized> Scan for Box<S> {
504504
}
505505

506506
#[inline]
507-
fn read_token(&mut self) -> Result<Token> {
507+
fn read_token(&mut self) -> Result<Token<'_>> {
508508
(**self).read_token()
509509
}
510510
}

crates/prettytty/src/conn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl Connection {
166166
/// to the terminal's input and output, respectively. Dropping them releases
167167
/// access again.
168168
#[inline]
169-
pub fn io(&self) -> (Input, Output) {
169+
pub fn io(&self) -> (Input<'_>, Output<'_>) {
170170
(self.input(), self.output())
171171
}
172172

@@ -179,7 +179,7 @@ impl Connection {
179179
///
180180
/// If the underlying mutex has been poisoned.
181181
#[inline]
182-
pub fn input(&self) -> Input {
182+
pub fn input(&self) -> Input<'_> {
183183
Input {
184184
scanner: self.scanner.lock().expect("can't lock poisoned mutex"),
185185
}
@@ -194,7 +194,7 @@ impl Connection {
194194
///
195195
/// If the underlying mutex has been poisoned.
196196
#[inline]
197-
pub fn output(&self) -> Output {
197+
pub fn output(&self) -> Output<'_> {
198198
Output {
199199
writer: self.writer.lock().expect("can't lock poisoned mutex"),
200200
}
@@ -325,7 +325,7 @@ impl Scan for Input<'_> {
325325
}
326326

327327
#[inline]
328-
fn read_token(&mut self) -> Result<crate::Token> {
328+
fn read_token(&mut self) -> Result<crate::Token<'_>> {
329329
self.scanner.read_token().map_err(core::convert::Into::into)
330330
}
331331
}

crates/prettytty/src/err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl From<Error> for std::io::Error {
144144
if let Some(error) = value.source {
145145
error
146146
} else {
147-
Self::new(std::io::ErrorKind::Other, value)
147+
Self::other(value)
148148
}
149149
}
150150
}

crates/prettytty/src/scan.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ impl<R: std::io::Read> Scanner<R> {
268268

269269
/// Create a control token for the byte.
270270
#[inline]
271-
fn new_control_token(&mut self, byte: u8) -> Result<Token, Error> {
271+
fn new_control_token(&mut self, byte: u8) -> Result<Token<'_>, Error> {
272272
self.extra[0] = byte;
273273
Ok(Token::Control(&self.extra))
274274
}
275275

276276
/// Create a new sequence token.
277277
#[inline]
278-
fn new_sequence_token(&self) -> Result<Token, Error> {
278+
fn new_sequence_token(&self) -> Result<Token<'_>, Error> {
279279
if self.did_overflow {
280280
Err(ErrorKind::OutOfMemory.into())
281281
} else {
@@ -289,7 +289,7 @@ impl<R: std::io::Read> Scanner<R> {
289289
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
290290

291291
/// Read the next token.
292-
pub fn read_token(&mut self) -> Result<Token, Error> {
292+
pub fn read_token(&mut self) -> Result<Token<'_>, Error> {
293293
loop {
294294
// Make sure that we have some bytes to process
295295
if let Some(0) = self.ensure_readable()? {

crates/prettytty/src/util.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ impl ByteFormat<'_> {
238238
Ok(characters)
239239
}
240240

241+
// Grr, if I add the annotation to the offending for loop over pairs, it is
242+
// ineffective.
243+
#[allow(clippy::missing_asserts_for_indexing)]
241244
fn render_hexdump<W>(bytes: &[u8], writer: &mut W) -> Result<usize, fmt::Error>
242245
where
243246
W: fmt::Write + ?Sized,
@@ -257,12 +260,11 @@ impl ByteFormat<'_> {
257260

258261
for pair in chunk.chunks(2) {
259262
// Allow for uneven number of bytes in final chunk.
260-
assert!(!pair.is_empty(), "chunk must not be empty");
263+
write!(writer, "{:02x}", pair[0])?;
261264
if pair.len() == 1 {
262-
write!(writer, "{:02x} ", pair[0])?;
265+
write!(writer, " ")?;
263266
} else {
264-
assert!(pair.len() == 2, "chunk has two elements");
265-
write!(writer, "{:02x}{:02x} ", pair[0], pair[1])?;
267+
write!(writer, "{:02x} ", pair[1])?;
266268
}
267269
characters += 5;
268270
}

0 commit comments

Comments
 (0)