Unfortunately I'm unable to implement Debug trait by myself. Hence I'm looking for help here.
use std::{collections::HashMap, fmt::Debug};
lazy_static! {
pub static ref REGION_LOCATION: HashMap<&'static str, Vec<&'static str>> = [
("de", vec!["fra", "txl"]),
("us", vec!["las", "ewr"]),
("gb", vec!["lhr"])
]
.iter()
.cloned()
.collect();
}
impl std::fmt::Debug for REGION_LOCATION {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut inner: Vec<String> = Vec::with_capacity(REGION_LOCATION.len());
for (key, val) in REGION_LOCATION.iter() {
let l = val.join(", ");
let item = format!("{{{}: [{}]}}", key, l).to_owned();
inner.push(item.to_owned());
}
std::fmt::Debug::fmt(inner.as_ref(), f)
}
}
The compiler asked for type annotatons, but I a newbie don't now how to do that. Could one more experienced developer help me to solve the issue?
error[E0283]: type annotations needed
--> src/ionos/cloud/api/v5/locations.rs:22:9
|
22 | std::fmt::Debug::fmt(inner.as_ref(), f)
| ^^^^^^^^^^^^^^^^^^^^ -------------- this method call resolves to `&T`
| |
| cannot infer type
|
= note: cannot satisfy `_: Debug`
= note: required by `std::fmt::Debug::fmt`
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0283`.
Thanks in advance!