File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
- Adds method ` into_buf ` for ` Box<Pointer> ` and ` impl From<PathBuf> for Box<Pointer> ` .
14
14
- Adds unsafe associated methods ` Pointer::new_unchecked ` and ` PointerBuf::new_unchecked ` for
15
15
external zero-cost construction.
16
+ - Adds ` Token::is_next ` for checking if a token represents the ` - ` character.
16
17
17
18
### Changed
18
19
Original file line number Diff line number Diff line change @@ -251,6 +251,13 @@ impl<'a> Token<'a> {
251
251
pub fn to_index ( & self ) -> Result < Index , ParseIndexError > {
252
252
self . try_into ( )
253
253
}
254
+
255
+ /// Returns if the `Token` is `-`, which stands for the next array index.
256
+ ///
257
+ /// See also [`Self::to_index`].
258
+ pub fn is_next ( & self ) -> bool {
259
+ matches ! ( self . to_index( ) , Ok ( Index :: Next ) )
260
+ }
254
261
}
255
262
256
263
macro_rules! impl_from_num {
@@ -491,4 +498,16 @@ mod tests {
491
498
]
492
499
} ) ;
493
500
}
501
+
502
+ #[ test]
503
+ fn is_next ( ) {
504
+ let token = Token :: new ( "-" ) ;
505
+ assert ! ( token. is_next( ) ) ;
506
+ let token = Token :: new ( "0" ) ;
507
+ assert ! ( !token. is_next( ) ) ;
508
+ let token = Token :: new ( "a" ) ;
509
+ assert ! ( !token. is_next( ) ) ;
510
+ let token = Token :: new ( "" ) ;
511
+ assert ! ( !token. is_next( ) ) ;
512
+ }
494
513
}
You can’t perform that action at this time.
0 commit comments