Fixed the rendering bug
This commit is contained in:
parent
227f40679e
commit
1bd26fb2ee
|
@ -493,13 +493,10 @@ pub struct SectionNumber(pub Vec<u32>);
|
||||||
|
|
||||||
impl Display for SectionNumber {
|
impl Display for SectionNumber {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
let dotted_number: String = self.0
|
for item in &self.0 {
|
||||||
.iter()
|
write!(f, "{}.", item)?;
|
||||||
.map(|i| i.to_string())
|
}
|
||||||
.collect::<Vec<String>>()
|
Ok(())
|
||||||
.join(".");
|
|
||||||
|
|
||||||
write!(f, "{}", dotted_number)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,9 +520,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn section_number_has_correct_dotted_representation() {
|
fn section_number_has_correct_dotted_representation() {
|
||||||
let inputs = vec![
|
let inputs = vec![
|
||||||
(vec![0], "0"),
|
(vec![0], "0."),
|
||||||
(vec![1, 3], "1.3"),
|
(vec![1, 3], "1.3."),
|
||||||
(vec![1, 2, 3], "1.2.3"),
|
(vec![1, 2, 3], "1.2.3."),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (input, should_be) in inputs {
|
for (input, should_be) in inputs {
|
||||||
|
|
Loading…
Reference in New Issue