simplify option_vec_printer
This commit is contained in:
parent
e40d6be883
commit
35dc36014d
12
src/misc.rs
12
src/misc.rs
@ -101,7 +101,6 @@ pub fn option_vec_printer<T: ToString>(data: &[Option<T>]) -> String
|
|||||||
where
|
where
|
||||||
T: ToString,
|
T: ToString,
|
||||||
{
|
{
|
||||||
let max_i: i32 = (data.len() as i32) - 1;
|
|
||||||
[
|
[
|
||||||
"[",
|
"[",
|
||||||
&data
|
&data
|
||||||
@ -111,16 +110,7 @@ where
|
|||||||
.map(|x_1| x_1.to_string())
|
.map(|x_1| x_1.to_string())
|
||||||
.unwrap_or_else(|| "None".to_owned())
|
.unwrap_or_else(|| "None".to_owned())
|
||||||
})
|
})
|
||||||
.enumerate()
|
.join(", "),
|
||||||
.map(|(i, x)| {
|
|
||||||
// Add comma and space if needed
|
|
||||||
match max_i > i as i32 {
|
|
||||||
true => x + ", ",
|
|
||||||
false => x,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
.concat(),
|
|
||||||
"]",
|
"]",
|
||||||
]
|
]
|
||||||
.concat()
|
.concat()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user