Skip to content

Commit f18dd12

Browse files
Clippy fixes
1 parent b57fdf3 commit f18dd12

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

src/decode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ pub fn decode_engine<E: Engine, T: AsRef<[u8]>>(
146146
///}
147147
///```
148148
#[cfg(any(feature = "alloc", feature = "std", test))]
149-
pub fn decode_engine_vec<'e, 'o, E: Engine, T: AsRef<[u8]>>(
149+
pub fn decode_engine_vec<E: Engine, T: AsRef<[u8]>>(
150150
input: T,
151-
buffer: &'o mut Vec<u8>,
152-
engine: &'e E,
151+
buffer: &mut Vec<u8>,
152+
engine: &E,
153153
) -> Result<(), DecodeError> {
154154
let input_bytes = input.as_ref();
155155

@@ -184,10 +184,10 @@ pub fn decode_engine_vec<'e, 'o, E: Engine, T: AsRef<[u8]>>(
184184
/// # Panics
185185
///
186186
/// If the slice is not large enough, this will panic.
187-
pub fn decode_engine_slice<'e, 'o, E: Engine, T: AsRef<[u8]>>(
187+
pub fn decode_engine_slice<E: Engine, T: AsRef<[u8]>>(
188188
input: T,
189-
output: &'o mut [u8],
190-
engine: &'e E,
189+
output: &mut [u8],
190+
engine: &E,
191191
) -> Result<usize, DecodeError> {
192192
let input_bytes = input.as_ref();
193193

src/encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ pub fn encode_engine_slice<E: Engine, T: AsRef<[u8]>>(
151151
let encoded_size = encoded_len(input_bytes.len(), engine.config().encode_padding())
152152
.expect("usize overflow when calculating buffer size");
153153

154-
let mut b64_output = &mut output_buf[0..encoded_size];
154+
let b64_output = &mut output_buf[0..encoded_size];
155155

156-
encode_with_padding(&input_bytes, &mut b64_output, engine, encoded_size);
156+
encode_with_padding(input_bytes, b64_output, engine, encoded_size);
157157

158158
encoded_size
159159
}

src/engine/fast_portable/decode.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,11 @@ fn decode_chunk(
319319
decode_table: &[u8; 256],
320320
output: &mut [u8],
321321
) -> Result<(), DecodeError> {
322-
let mut accum: u64;
323-
324322
let morsel = decode_table[input[0] as usize];
325323
if morsel == INVALID_VALUE {
326324
return Err(DecodeError::InvalidByte(index_at_start_of_input, input[0]));
327325
}
328-
accum = (morsel as u64) << 58;
326+
let mut accum: u64 = (morsel as u64) << 58;
329327

330328
let morsel = decode_table[input[1] as usize];
331329
if morsel == INVALID_VALUE {

src/engine/fast_portable/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ impl FastPortable {
2727
/// if the engine will be used repeatedly.
2828
pub const fn from(alphabet: &Alphabet, config: FastPortableConfig) -> FastPortable {
2929
FastPortable {
30-
encode_table: encode_table(&alphabet),
31-
decode_table: decode_table(&alphabet),
30+
encode_table: encode_table(alphabet),
31+
decode_table: decode_table(alphabet),
3232
config,
3333
}
3434
}
@@ -194,7 +194,7 @@ pub(crate) const fn encode_table(alphabet: &Alphabet) -> [u8; 64] {
194194
}
195195
}
196196

197-
return encode_table;
197+
encode_table
198198
}
199199

200200
/// Returns a table mapping base64 bytes as the lookup index to either:
@@ -213,7 +213,7 @@ pub(crate) const fn decode_table(alphabet: &Alphabet) -> [u8; 256] {
213213
index += 1;
214214
}
215215

216-
return decode_table;
216+
decode_table
217217
}
218218

219219
#[inline]

src/read/decoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'e, E: Engine, R: io::Read> DecoderReader<'e, E, R> {
9090
/// Returns a Result with the number of (decoded) bytes copied.
9191
fn flush_decoded_buf(&mut self, buf: &mut [u8]) -> io::Result<usize> {
9292
debug_assert!(self.decoded_len > 0);
93-
debug_assert!(buf.len() > 0);
93+
debug_assert!(!buf.is_empty());
9494

9595
let copy_len = cmp::min(self.decoded_len, buf.len());
9696
debug_assert!(copy_len > 0);
@@ -121,7 +121,7 @@ impl<'e, E: Engine, R: io::Read> DecoderReader<'e, E, R> {
121121

122122
debug_assert!(self.b64_offset + self.b64_len <= BUF_SIZE);
123123

124-
return Ok(read);
124+
Ok(read)
125125
}
126126

127127
/// Decode the requested number of bytes from the b64 buffer into the provided buffer. It's the
@@ -131,11 +131,11 @@ impl<'e, E: Engine, R: io::Read> DecoderReader<'e, E, R> {
131131
fn decode_to_buf(&mut self, num_bytes: usize, buf: &mut [u8]) -> io::Result<usize> {
132132
debug_assert!(self.b64_len >= num_bytes);
133133
debug_assert!(self.b64_offset + self.b64_len <= BUF_SIZE);
134-
debug_assert!(buf.len() > 0);
134+
debug_assert!(!buf.is_empty());
135135

136136
let decoded = decode_engine_slice(
137137
&self.b64_buffer[self.b64_offset..self.b64_offset + num_bytes],
138-
&mut buf[..],
138+
buf,
139139
self.engine,
140140
)
141141
.map_err(|e| match e {
@@ -183,7 +183,7 @@ impl<'e, E: Engine, R: Read> Read for DecoderReader<'e, E, R> {
183183
/// Any errors emitted by the delegate reader are returned. Decoding errors due to invalid
184184
/// base64 are also possible, and will have `io::ErrorKind::InvalidData`.
185185
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
186-
if buf.len() == 0 {
186+
if buf.is_empty() {
187187
return Ok(0);
188188
}
189189

0 commit comments

Comments
 (0)