fix: improve Display impl on Data
This commit is contained in:
parent
909966e475
commit
7612956830
|
@ -52,9 +52,9 @@ impl Display for Data<'_> {
|
||||||
match self {
|
match self {
|
||||||
Data::String(s) => f.write_str(&String::from_utf8_lossy(s)),
|
Data::String(s) => f.write_str(&String::from_utf8_lossy(s)),
|
||||||
Data::Double(s) => write!(f, "{s}"),
|
Data::Double(s) => write!(f, "{s}"),
|
||||||
Data::Bytes(s) => f.write_fmt(format_args!("{:?}", s)),
|
Data::Bytes(s) => write!(f, "{s:?}"),
|
||||||
Data::U16(s) => f.write_str(&s.to_string()),
|
Data::U16(s) => write!(f, "{s}"),
|
||||||
Data::U32(s) => f.write_str(&s.to_string()),
|
Data::U32(s) => write!(f, "{s}"),
|
||||||
Data::Map(hash_map) => {
|
Data::Map(hash_map) => {
|
||||||
for (k, v) in hash_map {
|
for (k, v) in hash_map {
|
||||||
f.write_fmt(format_args!("{} => {}\n", String::from_utf8_lossy(k), v))
|
f.write_fmt(format_args!("{} => {}\n", String::from_utf8_lossy(k), v))
|
||||||
|
@ -62,9 +62,9 @@ impl Display for Data<'_> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Data::I32(s) => f.write_str(&s.to_string()),
|
Data::I32(s) => write!(f, "{s}"),
|
||||||
Data::U64(s) => f.write_str(&s.to_string()),
|
Data::U64(s) => write!(f, "{s}"),
|
||||||
Data::U128(s) => f.write_str(&s.to_string()),
|
Data::U128(s) => write!(f, "{s}"),
|
||||||
Data::Array(vec) => {
|
Data::Array(vec) => {
|
||||||
for (i, v) in vec.iter().enumerate() {
|
for (i, v) in vec.iter().enumerate() {
|
||||||
f.write_fmt(format_args!("index = {} value = {}\n", i, v))
|
f.write_fmt(format_args!("index = {} value = {}\n", i, v))
|
||||||
|
@ -73,9 +73,9 @@ impl Display for Data<'_> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Data::DataCache => todo!(),
|
Data::DataCache => todo!(),
|
||||||
Data::End => f.write_str("END"),
|
Data::End => write!(f, "END"),
|
||||||
Data::Boolean(s) => f.write_str(&s.to_string()),
|
Data::Boolean(s) => write!(f, "{s}"),
|
||||||
Data::Float(s) => f.write_str(&s.to_string()),
|
Data::Float(s) => write!(f, "{s}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,11 +287,8 @@ impl MaxmindDB {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map(&self, offset: usize, read: usize, length: usize) -> (Data, usize) {
|
fn read_map(&self, offset: usize, mut read: usize, mut length: usize) -> (Data, usize) {
|
||||||
let mut map = FxHashMap::with_capacity_and_hasher(length, Default::default());
|
let mut map = FxHashMap::with_capacity_and_hasher(length, Default::default());
|
||||||
// length is number of elements
|
|
||||||
let mut length = length;
|
|
||||||
let mut read = read;
|
|
||||||
|
|
||||||
while length > 0 {
|
while length > 0 {
|
||||||
let (key, r) = self.read_data(offset + read);
|
let (key, r) = self.read_data(offset + read);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user