@@ -46,7 +46,7 @@ impl PpAnn for NoAnn {}
4646pub struct State < ' a > {
4747 pub s : pp:: Printer < ' a > ,
4848 cm : Option < & ' a SourceMap > ,
49- comments : Option < Vec < comments:: Comment > > ,
49+ comments : Vec < comments:: Comment > ,
5050 cur_cmnt : usize ,
5151 ann : & ' a ( dyn PpAnn +' a ) ,
5252 is_expanded : bool
@@ -110,7 +110,7 @@ impl<'a> State<'a> {
110110 State {
111111 s : pp:: mk_printer ( out) ,
112112 cm : Some ( cm) ,
113- comments,
113+ comments : comments . unwrap_or_default ( ) ,
114114 cur_cmnt : 0 ,
115115 ann,
116116 is_expanded,
@@ -126,7 +126,7 @@ pub fn to_string<F>(f: F) -> String where
126126 let mut printer = State {
127127 s : pp:: mk_printer ( & mut wr) ,
128128 cm : None ,
129- comments : None ,
129+ comments : Vec :: new ( ) ,
130130 cur_cmnt : 0 ,
131131 ann : & NoAnn ,
132132 is_expanded : false
@@ -423,7 +423,7 @@ fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
423423
424424pub trait PrintState < ' a > {
425425 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 > ;
427427 fn cur_cmnt ( & mut self ) -> & mut usize ;
428428
429429 fn word_space < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
@@ -550,15 +550,11 @@ pub trait PrintState<'a> {
550550
551551 fn next_comment ( & mut self ) -> Option < comments:: Comment > {
552552 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
562558 }
563559 }
564560
@@ -756,7 +752,7 @@ impl<'a> PrintState<'a> for State<'a> {
756752 & mut self . s
757753 }
758754
759- fn comments ( & mut self ) -> & mut Option < Vec < comments:: Comment > > {
755+ fn comments ( & mut self ) -> & mut Vec < comments:: Comment > {
760756 & mut self . comments
761757 }
762758
0 commit comments