Various clippy fixes

This commit is contained in:
Ivan Smirnov 2022-10-17 00:34:11 +01:00
parent 9fdca30f9e
commit bd00948952
3 changed files with 9 additions and 7 deletions

View file

@ -318,12 +318,13 @@ impl<R: Read> Decoder<R> {
/// Returns an immutable reference to the underlying reader.
#[inline]
pub fn reader(&self) -> &R {
pub const fn reader(&self) -> &R {
&self.reader
}
/// Consumes the decoder and returns the underlying reader back.
#[inline]
#[allow(clippy::missing_const_for_fn)]
pub fn into_reader(self) -> R {
self.reader
}
@ -343,7 +344,7 @@ impl<R: Reader> Decoder<R> {
/// to decode RGB into RGBA (in which case the alpha channel will be set
/// to 255), and vice versa (in which case the alpha channel will be ignored).
#[inline]
pub fn with_channels(mut self, channels: Channels) -> Self {
pub const fn with_channels(mut self, channels: Channels) -> Self {
self.channels = channels;
self
}
@ -352,13 +353,13 @@ impl<R: Reader> Decoder<R> {
///
/// Note: this may differ from the number of channels specified in the header.
#[inline]
pub fn channels(&self) -> Channels {
pub const fn channels(&self) -> Channels {
self.channels
}
/// Returns the decoded image header.
#[inline]
pub fn header(&self) -> &Header {
pub const fn header(&self) -> &Header {
&self.header
}
@ -366,7 +367,7 @@ impl<R: Reader> Decoder<R> {
///
/// Can be used to pre-allocate the buffer to decode the image into.
#[inline]
pub fn required_buf_len(&self) -> usize {
pub const fn required_buf_len(&self) -> usize {
self.header.n_pixels().saturating_mul(self.channels.as_u8() as usize)
}

View file

@ -62,7 +62,8 @@
clippy::must_use_candidate,
clippy::module_name_repetitions,
clippy::cargo_common_metadata,
clippy::doc_markdown
clippy::doc_markdown,
clippy::return_self_not_must_use,
)]
#![cfg_attr(not(any(feature = "std", test)), no_std)]
#[cfg(all(feature = "alloc", not(any(feature = "std", test))))]

View file

@ -84,7 +84,7 @@ pub struct GenericWriter<W> {
#[cfg(feature = "std")]
impl<W: Write> GenericWriter<W> {
pub fn new(writer: W) -> Self {
pub const fn new(writer: W) -> Self {
Self { writer, n_written: 0 }
}
}