Skip to content

Commit ced516a

Browse files
authored
fix new clippy lints (#1850)
1 parent e2a8d68 commit ced516a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

runtimes/core/src/base32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn encode(alphabet: Alphabet, data: &[u8]) -> String {
2121
Alphabet::Crockford => (CROCKFORD_ALPHABET, false),
2222
Alphabet::Encore => (ENCORE_ALPHABET, false),
2323
};
24-
let mut ret = Vec::with_capacity((data.len() + 3) / 4 * 5);
24+
let mut ret = Vec::with_capacity(data.len().div_ceil(4) * 5);
2525

2626
for chunk in data.chunks(5) {
2727
let buf = {
@@ -43,7 +43,7 @@ pub fn encode(alphabet: Alphabet, data: &[u8]) -> String {
4343

4444
if data.len() % 5 != 0 {
4545
let len = ret.len();
46-
let num_extra = 8 - (data.len() % 5 * 8 + 4) / 5;
46+
let num_extra = 8 - (data.len() % 5 * 8).div_ceil(5);
4747
if padding {
4848
for i in 1..num_extra + 1 {
4949
ret[len - i] = b'=';
@@ -87,7 +87,7 @@ pub fn decode(alphabet: Alphabet, data: &str) -> Option<Vec<u8>> {
8787
unpadded_data_length -= 1;
8888
}
8989
let output_length = unpadded_data_length * 5 / 8;
90-
let mut ret = Vec::with_capacity((output_length + 4) / 5 * 5);
90+
let mut ret = Vec::with_capacity(output_length.div_ceil(5) * 5);
9191
for chunk in data.chunks(8) {
9292
let buf = {
9393
let mut buf = [0u8; 8];

0 commit comments

Comments
 (0)