Skip to content

Commit 47ebe21

Browse files
committed
fix: use variables directly in format! string
Clippy will complain if the variables are not used directly in the string.
1 parent 4028c36 commit 47ebe21

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/eth.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ fn parse_type(
205205
if typ.ends_with(']') {
206206
let index = typ
207207
.rfind('[')
208-
.ok_or(format!("Invalid type format: {}", typ))?;
208+
.ok_or(format!("Invalid type format: {typ}"))?;
209209
let (rest, size) = (&typ[..index], &typ[index + 1..typ.len() - 1]);
210210
let size_int = if !size.is_empty() {
211-
u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))?
211+
u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))?
212212
} else {
213213
0
214214
};
@@ -221,7 +221,7 @@ fn parse_type(
221221
})
222222
} else if let Some(size) = typ.strip_prefix("bytes") {
223223
let size_int = if !size.is_empty() {
224-
u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))?
224+
u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))?
225225
} else {
226226
0
227227
};
@@ -235,7 +235,7 @@ fn parse_type(
235235
if size.is_empty() {
236236
return Err("uint must be sized".to_string());
237237
}
238-
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))? / 8;
238+
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))? / 8;
239239
Ok(MemberType {
240240
r#type: DataType::Uint.into(),
241241
size: size_int,
@@ -246,7 +246,7 @@ fn parse_type(
246246
if size.is_empty() {
247247
return Err("int must be sized".to_string());
248248
}
249-
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))? / 8;
249+
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))? / 8;
250250
Ok(MemberType {
251251
r#type: DataType::Int.into(),
252252
size: size_int,
@@ -282,7 +282,7 @@ fn parse_type(
282282
array_type: None,
283283
})
284284
} else {
285-
Err(format!("Can't recognize type: {}", typ))
285+
Err(format!("Can't recognize type: {typ}"))
286286
}
287287
}
288288

@@ -303,7 +303,7 @@ fn encode_value(typ: &MemberType, value: &Value) -> Result<Vec<u8>, String> {
303303
Value::String(v) => {
304304
if v.starts_with("0x") || v.starts_with("0X") {
305305
Ok(BigUint::parse_bytes(&v.as_bytes()[2..], 16)
306-
.ok_or(format!("could not parse {} as hex", v))?
306+
.ok_or(format!("could not parse {v} as hex"))?
307307
.to_bytes_be())
308308
} else {
309309
Ok(BigUint::from_str(v)

tests/util/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Server {
5858
let reader = std::io::BufReader::new(stdout);
5959
for line in reader.lines() {
6060
match line {
61-
Ok(line) => println!("\t\t{}", line),
62-
Err(e) => eprintln!("Error reading line: {}", e),
61+
Ok(line) => println!("\t\t{line}"),
62+
Err(e) => eprintln!("Error reading line: {e}"),
6363
}
6464
}
6565
});
@@ -127,7 +127,7 @@ async fn download_simulators() -> Result<Vec<String>, ()> {
127127
.await
128128
.map_err(|_| ())?
129129
{
130-
println!("Downloading simulator: {}", sim_url);
130+
println!("Downloading simulator: {sim_url}");
131131
download_file(&simulator.url, &filename)
132132
.await
133133
.map_err(|_| ())?;
@@ -168,7 +168,7 @@ pub async fn test_simulators_after_pairing(
168168
};
169169
for simulator_filename in simulator_filenames {
170170
println!();
171-
println!("\tSimulator tests using {}", simulator_filename);
171+
println!("\tSimulator tests using {simulator_filename}");
172172
let _server = Server::launch(&simulator_filename);
173173
let noise_config = Box::new(bitbox_api::NoiseConfigNoCache {});
174174
let bitbox = bitbox_api::BitBox::<bitbox_api::runtime::TokioRuntime>::from_simulator(

0 commit comments

Comments
 (0)