From 080d0c7f0ab26320d31f3429e8cd79bd3ffb6991 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 9 Jul 2019 11:15:31 +0200 Subject: [PATCH] Use pulldown types and force deref to compare with string slice --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3534703..5c4e62e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,13 +2,13 @@ extern crate mdbook; extern crate pulldown_cmark; extern crate pulldown_cmark_to_cmark; -use std::borrow::Cow; use mdbook::errors::{Error, Result}; use mdbook::book::{Book, BookItem, Chapter}; use mdbook::preprocess::{Preprocessor, PreprocessorContext}; use pulldown_cmark::{Event, Parser}; use pulldown_cmark::Tag::*; use pulldown_cmark_to_cmark::fmt::cmark; +use pulldown_cmark::CowStr; pub struct Toc; @@ -35,7 +35,7 @@ impl Preprocessor for Toc { } } -fn build_toc<'a>(toc: &[(i32, Cow<'a, str>)]) -> String { +fn build_toc<'a>(toc: &[(i32, CowStr<'a>)]) -> String { let mut result = String::new(); for (level, name) in toc { @@ -57,7 +57,7 @@ fn add_toc(content: &str) -> Result { for e in Parser::new(&content) { if let Event::Html(html) = e { - if html == "\n" { + if &*html == "\n" { toc_found = true; } continue; @@ -90,7 +90,7 @@ fn add_toc(content: &str) -> Result { let events = Parser::new(&content).map(|e| { if let Event::Html(html) = e.clone() { - if html == "\n" { + if &*html == "\n" { return toc_events.clone(); } }