@@ -78,8 +78,8 @@ impl<'a> PathParser<'a> {
78
78
( self . len ( ) == 1 ) . then ( || * * self . segments ( ) . next ( ) . as_ref ( ) . unwrap ( ) )
79
79
}
80
80
81
- pub fn word_or_empty ( & self ) -> Ident {
82
- self . word ( ) . unwrap_or_else ( Ident :: empty )
81
+ pub fn word_sym ( & self ) -> Option < Symbol > {
82
+ self . word ( ) . map ( |ident| ident . name )
83
83
}
84
84
85
85
/// Asserts that this MetaItem is some specific word.
@@ -253,71 +253,28 @@ impl<'a> MetaItemParser<'a> {
253
253
}
254
254
}
255
255
256
- /// Gets just the path, without the args.
257
- pub fn path_without_args ( & self ) -> PathParser < ' a > {
258
- self . path . clone ( )
259
- }
260
-
261
- /// Gets just the args parser, without caring about the path.
262
- pub fn args ( & self ) -> & ArgParser < ' a > {
263
- & self . args
264
- }
265
-
266
- pub fn deconstruct ( & self ) -> ( PathParser < ' a > , & ArgParser < ' a > ) {
267
- ( self . path_without_args ( ) , self . args ( ) )
268
- }
269
-
270
- /// Asserts that this MetaItem starts with a path. Some examples:
256
+ /// Gets a `PathParser` for a path. Some examples:
271
257
///
272
258
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path
273
259
/// - `#[allow(clippy::complexity)]`: `clippy::complexity` is a path
274
260
/// - `#[inline]`: `inline` is a single segment path
275
- pub fn path ( & self ) -> ( PathParser < ' a > , & ArgParser < ' a > ) {
276
- self . deconstruct ( )
277
- }
278
-
279
- /// Asserts that this MetaItem starts with a word, or single segment path.
280
- /// Doesn't return the args parser.
281
- ///
282
- /// For examples. see [`Self::word`]
283
- pub fn word_without_args ( & self ) -> Option < Ident > {
284
- Some ( self . word ( ) ?. 0 )
261
+ pub fn path ( & self ) -> & PathParser < ' a > {
262
+ & self . path
285
263
}
286
264
287
- /// Like [`word`](Self::word), but returns an empty symbol instead of None
288
- pub fn word_or_empty_without_args ( & self ) -> Ident {
289
- self . word_or_empty ( ) . 0
265
+ /// Gets just the args parser, without caring about the path.
266
+ pub fn args ( & self ) -> & ArgParser < ' a > {
267
+ & self . args
290
268
}
291
269
292
- /// Asserts that this MetaItem starts with a word, or single segment path .
270
+ /// Asserts that this MetaItem starts with some specific word .
293
271
///
294
272
/// Some examples:
295
273
/// - `#[inline]`: `inline` is a word
296
274
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
297
275
/// and not a word and should instead be parsed using [`path`](Self::path)
298
- pub fn word ( & self ) -> Option < ( Ident , & ArgParser < ' a > ) > {
299
- let ( path, args) = self . deconstruct ( ) ;
300
- Some ( ( path. word ( ) ?, args) )
301
- }
302
-
303
- /// Like [`word`](Self::word), but returns an empty symbol instead of None
304
- pub fn word_or_empty ( & self ) -> ( Ident , & ArgParser < ' a > ) {
305
- let ( path, args) = self . deconstruct ( ) ;
306
- ( path. word ( ) . unwrap_or ( Ident :: empty ( ) ) , args)
307
- }
308
-
309
- /// Asserts that this MetaItem starts with some specific word.
310
- ///
311
- /// See [`word`](Self::word) for examples of what a word is.
312
276
pub fn word_is ( & self , sym : Symbol ) -> Option < & ArgParser < ' a > > {
313
- self . path_without_args ( ) . word_is ( sym) . then ( || self . args ( ) )
314
- }
315
-
316
- /// Asserts that this MetaItem starts with some specific path.
317
- ///
318
- /// See [`word`](Self::path) for examples of what a word is.
319
- pub fn path_is ( & self , segments : & [ Symbol ] ) -> Option < & ArgParser < ' a > > {
320
- self . path_without_args ( ) . segments_is ( segments) . then ( || self . args ( ) )
277
+ self . path ( ) . word_is ( sym) . then ( || self . args ( ) )
321
278
}
322
279
}
323
280
@@ -562,7 +519,7 @@ impl<'a> MetaItemListParser<'a> {
562
519
}
563
520
564
521
/// Lets you pick and choose as what you want to parse each element in the list
565
- pub fn mixed < ' s > ( & ' s self ) -> impl Iterator < Item = & ' s MetaItemOrLitParser < ' a > > + ' s {
522
+ pub fn mixed ( & self ) -> impl Iterator < Item = & MetaItemOrLitParser < ' a > > + ' _ {
566
523
self . sub_parsers . iter ( )
567
524
}
568
525
@@ -574,20 +531,6 @@ impl<'a> MetaItemListParser<'a> {
574
531
self . len ( ) == 0
575
532
}
576
533
577
- /// Asserts that every item in the list is another list starting with a word.
578
- ///
579
- /// See [`MetaItemParser::word`] for examples of words.
580
- pub fn all_word_list < ' s > ( & ' s self ) -> Option < Vec < ( Ident , & ' s ArgParser < ' a > ) > > {
581
- self . mixed ( ) . map ( |i| i. meta_item ( ) ?. word ( ) ) . collect ( )
582
- }
583
-
584
- /// Asserts that every item in the list is another list starting with a full path.
585
- ///
586
- /// See [`MetaItemParser::path`] for examples of paths.
587
- pub fn all_path_list < ' s > ( & ' s self ) -> Option < Vec < ( PathParser < ' a > , & ' s ArgParser < ' a > ) > > {
588
- self . mixed ( ) . map ( |i| Some ( i. meta_item ( ) ?. path ( ) ) ) . collect ( )
589
- }
590
-
591
534
/// Returns Some if the list contains only a single element.
592
535
///
593
536
/// Inside the Some is the parser to parse this single element.
0 commit comments