@@ -253,60 +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 ( )
261
+ pub fn path ( & self ) -> & PathParser < ' a > {
262
+ & self . path
277
263
}
278
264
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 )
265
+ /// Gets just the args parser, without caring about the path.
266
+ pub fn args ( & self ) -> & ArgParser < ' a > {
267
+ & self . args
285
268
}
286
269
287
- /// Asserts that this MetaItem starts with a word, or single segment path .
270
+ /// Asserts that this MetaItem starts with some specific word .
288
271
///
289
272
/// Some examples:
290
273
/// - `#[inline]`: `inline` is a word
291
274
/// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
292
275
/// and not a word and should instead be parsed using [`path`](Self::path)
293
- pub fn word ( & self ) -> Option < ( Ident , & ArgParser < ' a > ) > {
294
- let ( path, args) = self . deconstruct ( ) ;
295
- Some ( ( path. word ( ) ?, args) )
296
- }
297
-
298
- /// Asserts that this MetaItem starts with some specific word.
299
- ///
300
- /// See [`word`](Self::word) for examples of what a word is.
301
276
pub fn word_is ( & self , sym : Symbol ) -> Option < & ArgParser < ' a > > {
302
- self . path_without_args ( ) . word_is ( sym) . then ( || self . args ( ) )
303
- }
304
-
305
- /// Asserts that this MetaItem starts with some specific path.
306
- ///
307
- /// See [`word`](Self::path) for examples of what a word is.
308
- pub fn path_is ( & self , segments : & [ Symbol ] ) -> Option < & ArgParser < ' a > > {
309
- self . path_without_args ( ) . segments_is ( segments) . then ( || self . args ( ) )
277
+ self . path ( ) . word_is ( sym) . then ( || self . args ( ) )
310
278
}
311
279
}
312
280
@@ -549,7 +517,7 @@ impl<'a> MetaItemListParser<'a> {
549
517
}
550
518
551
519
/// Lets you pick and choose as what you want to parse each element in the list
552
- pub fn mixed < ' s > ( & ' s self ) -> impl Iterator < Item = & ' s MetaItemOrLitParser < ' a > > + ' s {
520
+ pub fn mixed ( & self ) -> impl Iterator < Item = & MetaItemOrLitParser < ' a > > + ' _ {
553
521
self . sub_parsers . iter ( )
554
522
}
555
523
@@ -561,20 +529,6 @@ impl<'a> MetaItemListParser<'a> {
561
529
self . len ( ) == 0
562
530
}
563
531
564
- /// Asserts that every item in the list is another list starting with a word.
565
- ///
566
- /// See [`MetaItemParser::word`] for examples of words.
567
- pub fn all_word_list < ' s > ( & ' s self ) -> Option < Vec < ( Ident , & ' s ArgParser < ' a > ) > > {
568
- self . mixed ( ) . map ( |i| i. meta_item ( ) ?. word ( ) ) . collect ( )
569
- }
570
-
571
- /// Asserts that every item in the list is another list starting with a full path.
572
- ///
573
- /// See [`MetaItemParser::path`] for examples of paths.
574
- pub fn all_path_list < ' s > ( & ' s self ) -> Option < Vec < ( PathParser < ' a > , & ' s ArgParser < ' a > ) > > {
575
- self . mixed ( ) . map ( |i| Some ( i. meta_item ( ) ?. path ( ) ) ) . collect ( )
576
- }
577
-
578
532
/// Returns Some if the list contains only a single element.
579
533
///
580
534
/// Inside the Some is the parser to parse this single element.
0 commit comments