@@ -28,11 +28,12 @@ pub struct Comments(Vec<CommentWithSpan>);
2828
2929impl Comments {
3030 pub ( crate ) fn push ( & mut self , comment : CommentWithSpan ) {
31- debug_assert ! ( self
32- . 0
33- . last( )
34- . map( |last| last. span < comment. span)
35- . unwrap_or( true ) ) ;
31+ debug_assert ! (
32+ self . 0
33+ . last( )
34+ . map( |last| last. span < comment. span)
35+ . unwrap_or( true )
36+ ) ;
3637 self . 0 . push ( comment) ;
3738 }
3839
@@ -44,6 +45,8 @@ impl Comments {
4445 self . start_index ( range. start_bound ( ) ) ,
4546 self . end_index ( range. end_bound ( ) ) ,
4647 ) ;
48+ debug_assert ! ( ( 0 ..=self . 0 . len( ) ) . contains( & start) ) ;
49+ debug_assert ! ( ( 0 ..=self . 0 . len( ) ) . contains( & end) ) ;
4750 // in case the user specified a reverse range
4851 Iter ( if start <= end {
4952 self . 0 [ start..end] . iter ( )
@@ -54,7 +57,7 @@ impl Comments {
5457
5558 /// Find the index of the first comment starting "before" the given location.
5659 ///
57- /// The returned index is _inclusive._
60+ /// The returned index is _inclusive_ and within the range of `0..=self.0.len()`.
5861 fn start_index ( & self , location : Bound < & Location > ) -> usize {
5962 match location {
6063 Bound :: Included ( location) => {
@@ -75,7 +78,7 @@ impl Comments {
7578
7679 /// Find the index of the first comment starting "after" the given location.
7780 ///
78- /// The returned index is _exclusive._
81+ /// The returned index is _exclusive_ and within the range of `0..=self.0.len()`.
7982 fn end_index ( & self , location : Bound < & Location > ) -> usize {
8083 match location {
8184 Bound :: Included ( location) => {
0 commit comments