Closed
Description
Code
use serde_json;
let idsmap: HashMap<String, u8> = serde_json::from_reader(fs::File::open("id_keys.json").expect("error 3"))
.expect("error 4");
println!({},idsmap.get("1stSpellCost"));
Current output
error: format argument must be a string literal
--> src/main.rs:55:14
|
55 | println!({},idsmap.get("1stSpellCost"));
| ^^
|
help: you might be missing a string literal to format with
|
55 | println!("{} {}", {},idsmap.get("1stSpellCost"));
| ++++++++
Desired output
error: format argument must be a string literal
--> src/main.rs:55:14
|
55 | println!({},idsmap.get("1stSpellCost"));
| ^^
|
help: you might be missing brackets
|
55 | println!("{}",idsmap.get("1stSpellCost"));
| + +
Rationale and extra context
Cargo does not seem to be detecting the {} outside brackets and provides an incredibly strange fix instead.
Other cases
No response
Rust Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Anything else?
the file is from here:
https://github.com/Wynntils/Static-Storage/blob/main/Reference/id_keys.json
You will need serde_json crate.