1
Fork 0

cargo fmt

This commit is contained in:
Jan-Erik Rediger 2021-01-06 14:27:35 +01:00
parent 6c96ceea1f
commit 01f2879e10

View file

@ -1,6 +1,7 @@
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Write; use std::fmt::Write;
use mdbook::book::{Book, BookItem, Chapter}; use mdbook::book::{Book, BookItem, Chapter};
use mdbook::errors::{Error, Result}; use mdbook::errors::{Error, Result};
use mdbook::preprocess::{Preprocessor, PreprocessorContext}; use mdbook::preprocess::{Preprocessor, PreprocessorContext};
@ -67,7 +68,7 @@ fn build_toc(toc: &[(u32, String, String)]) -> String {
// Start from the level of the first header. // Start from the level of the first header.
let mut last_lower = match toc_iter.peek() { let mut last_lower = match toc_iter.peek() {
Some((lvl, _, _)) => *lvl, Some((lvl, _, _)) => *lvl,
None => 0 None => 0,
}; };
let toc = toc.iter().map(|(lvl, name, slug)| { let toc = toc.iter().map(|(lvl, name, slug)| {
let lvl = *lvl; let lvl = *lvl;
@ -190,7 +191,10 @@ fn add_toc(content: &str, marker: &str) -> Result<String> {
}) })
.flatten(); .flatten();
let opts = COptions { newlines_after_codeblock: 1, ..Default::default() }; let opts = COptions {
newlines_after_codeblock: 1,
..Default::default()
};
cmark_with_options(events, &mut buf, None, opts) cmark_with_options(events, &mut buf, None, opts)
.map(|_| buf) .map(|_| buf)
.map_err(|err| Error::msg(format!("Markdown serialization failed: {}", err))) .map_err(|err| Error::msg(format!("Markdown serialization failed: {}", err)))
@ -248,10 +252,7 @@ mod test {
### Header 2.2.1"#; ### Header 2.2.1"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]
@ -284,10 +285,7 @@ mod test {
## Header 2.1"#; ## Header 2.1"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]
@ -309,10 +307,7 @@ mod test {
|------|------| |------|------|
|Row 1|Row 2|"#; |Row 1|Row 2|"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]
@ -361,10 +356,7 @@ mod test {
# Another header `with inline` code"#; # Another header `with inline` code"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]
@ -411,10 +403,7 @@ mod test {
## User Preferences"#; ## User Preferences"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]
@ -451,10 +440,7 @@ text"#;
text"#; text"#;
assert_eq!( assert_eq!(expected, add_toc(content, DEFAULT_MARKER).unwrap());
expected,
add_toc(content, DEFAULT_MARKER).unwrap()
);
} }
#[test] #[test]