chore: update format! macro use to satisfy latest clippy version (#194)

This commit is contained in:
Louise Poole
2025-04-25 17:13:01 +02:00
committed by GitHub
parent 9740c92129
commit f29de67f1f
38 changed files with 1379 additions and 1698 deletions

View File

@@ -108,7 +108,7 @@ impl<'a> UniswapPoolStorage<'a> {
// We need this to keep the references to the names alive until we call
// `get_changed_attributes()`
for tick_idx in ticks_idx.iter() {
tick_names.push(format!("ticks/{}/net-liquidity", tick_idx));
tick_names.push(format!("ticks/{tick_idx}/net-liquidity"));
}
// Then, iterate over ticks_idx and tick_names simultaneously

View File

@@ -32,30 +32,18 @@ pub fn left_pad(input: &[u8], padding_value: u8) -> [u8; 32] {
pub fn read_bytes(buf: &[u8], offset: usize, number_of_bytes: usize) -> &[u8] {
let buf_length = buf.len();
if buf_length < number_of_bytes {
panic!(
"attempting to read {number_of_bytes} bytes in buffer size {buf_size}",
number_of_bytes = number_of_bytes,
buf_size = buf.len()
)
panic!("attempting to read {number_of_bytes} bytes in buffer size {buf_length}",)
}
if offset > (buf_length - 1) {
panic!(
"offset {offset} exceeds buffer size {buf_size}",
offset = offset,
buf_size = buf.len()
)
panic!("offset {offset} exceeds buffer size {buf_length}")
}
let end = buf_length - 1 - offset;
let start_opt = (end + 1).checked_sub(number_of_bytes);
if start_opt.is_none() {
panic!(
"number of bytes {number_of_bytes} with offset {offset} exceeds buffer size
{buf_size}",
number_of_bytes = number_of_bytes,
offset = offset,
buf_size = buf.len()
"number of bytes {number_of_bytes} with offset {offset} exceeds buffer size {buf_length}"
)
}
let start = start_opt.unwrap();
@@ -158,7 +146,7 @@ mod tests {
fn encode_hex(bytes: &[u8]) -> String {
let mut s = String::with_capacity(bytes.len() * 2);
for &b in bytes {
write!(&mut s, "{:02x}", b).unwrap();
write!(&mut s, "{b:02x}").unwrap();
}
s
}