Pass properties as integers internally

Raymon Zutekouw 2 days ago
parent 6458d2f0af
commit af063645c7
Signed by: raymon
GPG Key ID: 0E62222846283925
  1. 6
      src/lib.rs

@ -21,7 +21,7 @@ pub mod wikipedia_infobox_analyzer {
} }
/// Creates an ascii infobox out of the properties /// Creates an ascii infobox out of the properties
pub fn format_infobox_from_used_properties(name: String, properties: Vec<String>) -> String { pub fn format_infobox_from_used_properties(name: String, properties: Vec<u64>) -> String {
let mut ascii_table = AsciiTable::default(); let mut ascii_table = AsciiTable::default();
ascii_table.set_max_width(26); ascii_table.set_max_width(26);
ascii_table ascii_table
@ -29,7 +29,7 @@ pub mod wikipedia_infobox_analyzer {
.set_header(name) .set_header(name)
.set_align(Align::Left); .set_align(Align::Left);
let data: Vec<Vec<&String>> = properties.iter().map(|v| vec![v]).collect(); let data: Vec<Vec<String>> = properties.iter().map(|v| vec![format!("P{v}")]).collect();
ascii_table.format(data) ascii_table.format(data)
} }
@ -139,7 +139,7 @@ mod tests {
assert_eq!( assert_eq!(
format_infobox_from_used_properties( format_infobox_from_used_properties(
"Earth".to_string(), "Earth".to_string(),
vec!["P31".to_string(), "P361".to_string(), "P571".to_string()] vec![31, 361, 571]
), ),
concat![ concat![
"┌───────┐\n", "┌───────┐\n",

Loading…
Cancel
Save