Fixed the rendering bug

This commit is contained in:
Michael Bryan 2017-09-02 18:52:11 +08:00
parent 227f40679e
commit 1bd26fb2ee
1 changed files with 7 additions and 10 deletions

View File

@ -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 {