@@ -5,9 +5,9 @@ use std::{
55 iter:: Peekable ,
66} ;
77
8- const LISTING_DELIMITER : & ' static str = "----" ;
9- const IMAGE_BLOCK_PREFIX : & ' static str = "image::" ;
10- const VIDEO_BLOCK_PREFIX : & ' static str = "video::" ;
8+ const LISTING_DELIMITER : & str = "----" ;
9+ const IMAGE_BLOCK_PREFIX : & str = "image::" ;
10+ const VIDEO_BLOCK_PREFIX : & str = "video::" ;
1111
1212struct Converter < ' a , ' b , R : BufRead > {
1313 iter : & ' a mut Peekable < Lines < R > > ,
@@ -89,7 +89,7 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
8989 while let Some ( line) = self . iter . peek ( ) {
9090 let line = line. as_deref ( ) . map_err ( |e| anyhow ! ( "{e}" ) ) ?;
9191
92- if get_list_item ( & line) . is_some ( ) {
92+ if get_list_item ( line) . is_some ( ) {
9393 let line = self . iter . next ( ) . unwrap ( ) ?;
9494 let line = process_inline_macros ( & line) ?;
9595 let ( marker, item) = get_list_item ( & line) . unwrap ( ) ;
@@ -253,17 +253,16 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
253253 {
254254 while let Some ( line) = self . iter . peek ( ) {
255255 let line = line. as_deref ( ) . map_err ( |e| anyhow ! ( "{e}" ) ) ?;
256- if predicate ( & line) {
256+ if predicate ( line) {
257257 break ;
258258 }
259259
260260 self . write_indent ( level) ;
261261 let line = self . iter . next ( ) . unwrap ( ) ?;
262262 let line = line. trim_start ( ) ;
263- let line = process_inline_macros ( & line) ?;
264- if line. ends_with ( '+' ) {
265- let line = & line[ ..( line. len ( ) - 1 ) ] ;
266- self . output . push_str ( line) ;
263+ let line = process_inline_macros ( line) ?;
264+ if let Some ( stripped) = line. strip_suffix ( '+' ) {
265+ self . output . push_str ( stripped) ;
267266 self . output . push ( '\\' ) ;
268267 } else {
269268 self . output . push_str ( & line) ;
@@ -339,8 +338,8 @@ fn get_title(line: &str) -> Option<(usize, &str)> {
339338}
340339
341340fn get_list_item ( line : & str ) -> Option < ( ListMarker , & str ) > {
342- const HYPHYEN_MARKER : & ' static str = "- " ;
343- if let Some ( text) = line. strip_prefix ( HYPHYEN_MARKER ) {
341+ const HYPHEN_MARKER : & str = "- " ;
342+ if let Some ( text) = line. strip_prefix ( HYPHEN_MARKER ) {
344343 Some ( ( ListMarker :: Hyphen , text) )
345344 } else if let Some ( ( count, text) ) = strip_prefix_symbol ( line, '*' ) {
346345 Some ( ( ListMarker :: Asterisk ( count) , text) )
0 commit comments