@@ -5,9 +5,9 @@ use std::{
5
5
iter:: Peekable ,
6
6
} ;
7
7
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::" ;
11
11
12
12
struct Converter < ' a , ' b , R : BufRead > {
13
13
iter : & ' a mut Peekable < Lines < R > > ,
@@ -89,7 +89,7 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
89
89
while let Some ( line) = self . iter . peek ( ) {
90
90
let line = line. as_deref ( ) . map_err ( |e| anyhow ! ( "{e}" ) ) ?;
91
91
92
- if get_list_item ( & line) . is_some ( ) {
92
+ if get_list_item ( line) . is_some ( ) {
93
93
let line = self . iter . next ( ) . unwrap ( ) ?;
94
94
let line = process_inline_macros ( & line) ?;
95
95
let ( marker, item) = get_list_item ( & line) . unwrap ( ) ;
@@ -253,17 +253,16 @@ impl<'a, 'b, R: BufRead> Converter<'a, 'b, R> {
253
253
{
254
254
while let Some ( line) = self . iter . peek ( ) {
255
255
let line = line. as_deref ( ) . map_err ( |e| anyhow ! ( "{e}" ) ) ?;
256
- if predicate ( & line) {
256
+ if predicate ( line) {
257
257
break ;
258
258
}
259
259
260
260
self . write_indent ( level) ;
261
261
let line = self . iter . next ( ) . unwrap ( ) ?;
262
262
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) ;
267
266
self . output . push ( '\\' ) ;
268
267
} else {
269
268
self . output . push_str ( & line) ;
@@ -339,8 +338,8 @@ fn get_title(line: &str) -> Option<(usize, &str)> {
339
338
}
340
339
341
340
fn 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 ) {
344
343
Some ( ( ListMarker :: Hyphen , text) )
345
344
} else if let Some ( ( count, text) ) = strip_prefix_symbol ( line, '*' ) {
346
345
Some ( ( ListMarker :: Asterisk ( count) , text) )
0 commit comments