File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -58,21 +58,19 @@ impl CommentBlock {
5858 assert ! ( tag. starts_with( char :: is_uppercase) ) ;
5959
6060 let tag = format ! ( "{tag}:" ) ;
61- // Would be nice if we had `.retain_mut` here!
62- CommentBlock :: extract_untagged ( text)
63- . into_iter ( )
64- . filter_map ( |mut block| {
65- let first = block. contents . remove ( 0 ) ;
66- first. strip_prefix ( & tag) . map ( |id| {
67- if block. is_doc {
68- panic ! ( "Use plain (non-doc) comments with tags like {tag}:\n {first}" ) ;
69- }
61+ let mut blocks = CommentBlock :: extract_untagged ( text) ;
62+ blocks. retain_mut ( |block| {
63+ let first = block. contents . remove ( 0 ) ;
64+ let Some ( id) = first. strip_prefix ( & tag) else { return false ; } ;
65+
66+ if block. is_doc {
67+ panic ! ( "Use plain (non-doc) comments with tags like {tag}:\n {first}" ) ;
68+ }
7069
71- block. id = id. trim ( ) . to_string ( ) ;
72- block
73- } )
74- } )
75- . collect ( )
70+ block. id = id. trim ( ) . to_string ( ) ;
71+ true
72+ } ) ;
73+ blocks
7674 }
7775
7876 pub fn extract_untagged ( text : & str ) -> Vec < CommentBlock > {
You can’t perform that action at this time.
0 commit comments