fix code in doc

This commit is contained in:
Mathieu David 2015-09-11 21:01:34 +02:00
parent a050d9c4ad
commit a32d170667
1 changed files with 8 additions and 3 deletions

View File

@ -39,17 +39,22 @@ impl MDBook {
}
}
/// Returns a flat depth-first iterator over the elements of the book in the form of a tuple:
/// Returns a flat depth-first iterator over the elements of the book, it returns an [BookItem enum](bookitem.html):
/// `(section: String, bookitem: &BookItem)`
///
/// ```no_run
/// # extern crate mdbook;
/// # use mdbook::MDBook;
/// # use bookitem::BookItem;
/// # use std::path::Path;
/// # fn main() {
/// # let mut book = MDBook::new(Path::new("mybook"));
/// for (section, element) in book.iter() {
/// println!("{} {}", section, element.name);
/// for item in book.iter() {
/// match item {
/// BookItem::Chapter(section, chapter) => {},
/// BookItem::Affix(chapter) => {},
/// BookItem::Spacer => {},
/// }
/// }
///
/// // would print something like this: