@@ -46,7 +46,7 @@ impl PpAnn for NoAnn {}
46
46
pub struct State < ' a > {
47
47
pub s : pp:: Printer < ' a > ,
48
48
cm : Option < & ' a SourceMap > ,
49
- comments : Option < Vec < comments:: Comment > > ,
49
+ comments : Vec < comments:: Comment > ,
50
50
cur_cmnt : usize ,
51
51
ann : & ' a ( dyn PpAnn +' a ) ,
52
52
is_expanded : bool
@@ -110,7 +110,7 @@ impl<'a> State<'a> {
110
110
State {
111
111
s : pp:: mk_printer ( out) ,
112
112
cm : Some ( cm) ,
113
- comments,
113
+ comments : comments . unwrap_or_default ( ) ,
114
114
cur_cmnt : 0 ,
115
115
ann,
116
116
is_expanded,
@@ -126,7 +126,7 @@ pub fn to_string<F>(f: F) -> String where
126
126
let mut printer = State {
127
127
s : pp:: mk_printer ( & mut wr) ,
128
128
cm : None ,
129
- comments : None ,
129
+ comments : Vec :: new ( ) ,
130
130
cur_cmnt : 0 ,
131
131
ann : & NoAnn ,
132
132
is_expanded : false
@@ -423,7 +423,7 @@ fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
423
423
424
424
pub trait PrintState < ' a > {
425
425
fn writer ( & mut self ) -> & mut pp:: Printer < ' a > ;
426
- fn comments ( & mut self ) -> & mut Option < Vec < comments:: Comment > > ;
426
+ fn comments ( & mut self ) -> & mut Vec < comments:: Comment > ;
427
427
fn cur_cmnt ( & mut self ) -> & mut usize ;
428
428
429
429
fn word_space < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
@@ -550,15 +550,11 @@ pub trait PrintState<'a> {
550
550
551
551
fn next_comment ( & mut self ) -> Option < comments:: Comment > {
552
552
let cur_cmnt = * self . cur_cmnt ( ) ;
553
- match * self . comments ( ) {
554
- Some ( ref cmnts) => {
555
- if cur_cmnt < cmnts. len ( ) {
556
- Some ( cmnts[ cur_cmnt] . clone ( ) )
557
- } else {
558
- None
559
- }
560
- }
561
- _ => None
553
+ let cmnts = & * self . comments ( ) ;
554
+ if cur_cmnt < cmnts. len ( ) {
555
+ Some ( cmnts[ cur_cmnt] . clone ( ) )
556
+ } else {
557
+ None
562
558
}
563
559
}
564
560
@@ -756,7 +752,7 @@ impl<'a> PrintState<'a> for State<'a> {
756
752
& mut self . s
757
753
}
758
754
759
- fn comments ( & mut self ) -> & mut Option < Vec < comments:: Comment > > {
755
+ fn comments ( & mut self ) -> & mut Vec < comments:: Comment > {
760
756
& mut self . comments
761
757
}
762
758
0 commit comments