@@ -25,9 +25,7 @@ pub(crate) fn convert_comment_block(acc: &mut Assists, ctx: &AssistContext<'_>)
2525 let comment = ctx. find_token_at_offset :: < ast:: Comment > ( ) ?;
2626 // Only allow comments which are alone on their line
2727 if let Some ( prev) = comment. syntax ( ) . prev_token ( ) {
28- if Whitespace :: cast ( prev) . filter ( |w| w. text ( ) . contains ( '\n' ) ) . is_none ( ) {
29- return None ;
30- }
28+ Whitespace :: cast ( prev) . filter ( |w| w. text ( ) . contains ( '\n' ) ) ?;
3129 }
3230
3331 match comment. kind ( ) . shape {
@@ -86,10 +84,8 @@ fn line_to_block(acc: &mut Assists, comment: ast::Comment) -> Option<()> {
8684 // contents of each line comment when they're put into the block comment.
8785 let indentation = IndentLevel :: from_token ( comment. syntax ( ) ) ;
8886
89- let cms = comments
90- . into_iter ( )
91- . map ( |c| line_comment_text ( indentation, c) )
92- . collect :: < Option < Vec < String > > > ( ) ?;
87+ let cms =
88+ comments. into_iter ( ) . map ( |c| line_comment_text ( indentation, c) ) . collect :: < Vec < String > > ( ) ;
9389
9490 acc. add (
9591 AssistId ( "line_to_block" , AssistKind :: RefactorRewrite ) ,
@@ -163,16 +159,16 @@ pub(crate) fn relevant_line_comments(comment: &ast::Comment) -> Vec<Comment> {
163159// */
164160//
165161// But since such comments aren't idiomatic we're okay with this.
166- pub ( crate ) fn line_comment_text ( indentation : IndentLevel , comm : ast:: Comment ) -> Option < String > {
162+ pub ( crate ) fn line_comment_text ( indentation : IndentLevel , comm : ast:: Comment ) -> String {
167163 let text = comm. text ( ) ;
168164 let contents_without_prefix = text. strip_prefix ( comm. prefix ( ) ) . unwrap_or ( text) ;
169165 let contents = contents_without_prefix. strip_prefix ( ' ' ) . unwrap_or ( contents_without_prefix) ;
170166
171167 // Don't add the indentation if the line is empty
172168 if contents. is_empty ( ) {
173- Some ( contents. to_owned ( ) )
169+ contents. to_owned ( )
174170 } else {
175- Some ( indentation. to_string ( ) + contents)
171+ indentation. to_string ( ) + contents
176172 }
177173}
178174
0 commit comments