Skip to content

Commit 27f7ed1

Browse files
authored
Fix newer clippy errors (#1135)
These are mostly more lifetime elisions, and Option::is_some_and(f) replacing Option::map(false, f), see: https://github.com/pest-parser/pest/actions/runs/18968907018/job/54188036314 Fixes CI.
1 parent c51e047 commit 27f7ed1

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

pest/src/iterators/flat_pairs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'i, R: RuleType> FlatPairs<'i, R> {
9797
}
9898
}
9999

100-
impl<'i, R: RuleType> ExactSizeIterator for FlatPairs<'i, R> {
100+
impl<R: RuleType> ExactSizeIterator for FlatPairs<'_, R> {
101101
fn len(&self) -> usize {
102102
// Tokens len is exactly twice as flatten pairs len
103103
(self.end - self.start) >> 1
@@ -129,7 +129,7 @@ impl<'i, R: RuleType> Iterator for FlatPairs<'i, R> {
129129
}
130130
}
131131

132-
impl<'i, R: RuleType> DoubleEndedIterator for FlatPairs<'i, R> {
132+
impl<R: RuleType> DoubleEndedIterator for FlatPairs<'_, R> {
133133
fn next_back(&mut self) -> Option<Self::Item> {
134134
if self.end <= self.start {
135135
return None;
@@ -148,7 +148,7 @@ impl<'i, R: RuleType> DoubleEndedIterator for FlatPairs<'i, R> {
148148
}
149149
}
150150

151-
impl<'i, R: RuleType> fmt::Debug for FlatPairs<'i, R> {
151+
impl<R: RuleType> fmt::Debug for FlatPairs<'_, R> {
152152
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
153153
f.debug_struct("FlatPairs")
154154
.field("pairs", &self.clone().collect::<Vec<_>>())

pest/src/iterators/pair.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'i, R: RuleType> Pairs<'i, R> {
324324
}
325325
}
326326

327-
impl<'i, R: RuleType> fmt::Debug for Pair<'i, R> {
327+
impl<R: RuleType> fmt::Debug for Pair<'_, R> {
328328
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
329329
let pair = &mut f.debug_struct("Pair");
330330
pair.field("rule", &self.as_rule());
@@ -338,7 +338,7 @@ impl<'i, R: RuleType> fmt::Debug for Pair<'i, R> {
338338
}
339339
}
340340

341-
impl<'i, R: RuleType> fmt::Display for Pair<'i, R> {
341+
impl<R: RuleType> fmt::Display for Pair<'_, R> {
342342
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
343343
let rule = self.as_rule();
344344
let start = self.pos(self.start);
@@ -371,7 +371,7 @@ impl<'i, R: PartialEq> PartialEq for Pair<'i, R> {
371371
}
372372
}
373373

374-
impl<'i, R: Eq> Eq for Pair<'i, R> {}
374+
impl<R: Eq> Eq for Pair<'_, R> {}
375375

376376
impl<'i, R: Hash> Hash for Pair<'i, R> {
377377
fn hash<H: Hasher>(&self, state: &mut H) {
@@ -382,7 +382,7 @@ impl<'i, R: Hash> Hash for Pair<'i, R> {
382382
}
383383

384384
#[cfg(feature = "pretty-print")]
385-
impl<'i, R: RuleType> ::serde::Serialize for Pair<'i, R> {
385+
impl<R: RuleType> ::serde::Serialize for Pair<'_, R> {
386386
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
387387
where
388388
S: ::serde::Serializer,

pest/src/iterators/pairs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'i, R: RuleType> Pairs<'i, R> {
413413
}
414414
}
415415

416-
impl<'i, R: RuleType> ExactSizeIterator for Pairs<'i, R> {
416+
impl<R: RuleType> ExactSizeIterator for Pairs<'_, R> {
417417
#[inline]
418418
fn len(&self) -> usize {
419419
self.pairs_count
@@ -437,7 +437,7 @@ impl<'i, R: RuleType> Iterator for Pairs<'i, R> {
437437
}
438438
}
439439

440-
impl<'i, R: RuleType> DoubleEndedIterator for Pairs<'i, R> {
440+
impl<R: RuleType> DoubleEndedIterator for Pairs<'_, R> {
441441
fn next_back(&mut self) -> Option<Self::Item> {
442442
if self.end <= self.start {
443443
return None;
@@ -457,13 +457,13 @@ impl<'i, R: RuleType> DoubleEndedIterator for Pairs<'i, R> {
457457
}
458458
}
459459

460-
impl<'i, R: RuleType> fmt::Debug for Pairs<'i, R> {
460+
impl<R: RuleType> fmt::Debug for Pairs<'_, R> {
461461
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
462462
f.debug_list().entries(self.clone()).finish()
463463
}
464464
}
465465

466-
impl<'i, R: RuleType> fmt::Display for Pairs<'i, R> {
466+
impl<R: RuleType> fmt::Display for Pairs<'_, R> {
467467
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
468468
write!(
469469
f,
@@ -485,7 +485,7 @@ impl<'i, R: PartialEq> PartialEq for Pairs<'i, R> {
485485
}
486486
}
487487

488-
impl<'i, R: Eq> Eq for Pairs<'i, R> {}
488+
impl<R: Eq> Eq for Pairs<'_, R> {}
489489

490490
impl<'i, R: Hash> Hash for Pairs<'i, R> {
491491
fn hash<H: Hasher>(&self, state: &mut H) {
@@ -497,7 +497,7 @@ impl<'i, R: Hash> Hash for Pairs<'i, R> {
497497
}
498498

499499
#[cfg(feature = "pretty-print")]
500-
impl<'i, R: RuleType> ::serde::Serialize for Pairs<'i, R> {
500+
impl<R: RuleType> ::serde::Serialize for Pairs<'_, R> {
501501
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
502502
where
503503
S: ::serde::Serializer,

pest/src/iterators/tokens.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'i, R: RuleType> Tokens<'i, R> {
8484
}
8585
}
8686

87-
impl<'i, R: RuleType> ExactSizeIterator for Tokens<'i, R> {
87+
impl<R: RuleType> ExactSizeIterator for Tokens<'_, R> {
8888
fn len(&self) -> usize {
8989
self.end - self.start
9090
}
@@ -111,7 +111,7 @@ impl<'i, R: RuleType> Iterator for Tokens<'i, R> {
111111
}
112112
}
113113

114-
impl<'i, R: RuleType> DoubleEndedIterator for Tokens<'i, R> {
114+
impl<R: RuleType> DoubleEndedIterator for Tokens<'_, R> {
115115
fn next_back(&mut self) -> Option<Self::Item> {
116116
if self.end <= self.start {
117117
return None;
@@ -125,7 +125,7 @@ impl<'i, R: RuleType> DoubleEndedIterator for Tokens<'i, R> {
125125
}
126126
}
127127

128-
impl<'i, R: RuleType> fmt::Debug for Tokens<'i, R> {
128+
impl<R: RuleType> fmt::Debug for Tokens<'_, R> {
129129
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130130
f.debug_list().entries(self.clone()).finish()
131131
}

pest/src/parser_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl Default for CallLimitTracker {
137137
impl CallLimitTracker {
138138
fn limit_reached(&self) -> bool {
139139
self.current_call_limit
140-
.map_or(false, |(current, limit)| current >= limit)
140+
.is_some_and(|(current, limit)| current >= limit)
141141
}
142142

143143
fn increment_depth(&mut self) {

pest/src/position.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl<'i> Position<'i> {
441441
}
442442
}
443443

444-
impl<'i> fmt::Debug for Position<'i> {
444+
impl fmt::Debug for Position<'_> {
445445
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
446446
f.debug_struct("Position").field("pos", &self.pos).finish()
447447
}
@@ -453,7 +453,7 @@ impl<'i> PartialEq for Position<'i> {
453453
}
454454
}
455455

456-
impl<'i> Eq for Position<'i> {}
456+
impl Eq for Position<'_> {}
457457

458458
#[allow(clippy::non_canonical_partial_ord_impl)]
459459
impl<'i> PartialOrd for Position<'i> {
@@ -473,7 +473,7 @@ impl<'i> Ord for Position<'i> {
473473
}
474474
}
475475

476-
impl<'i> Hash for Position<'i> {
476+
impl Hash for Position<'_> {
477477
fn hash<H: Hasher>(&self, state: &mut H) {
478478
(self.input as *const str).hash(state);
479479
self.pos.hash(state);

pest/src/span.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'i> Span<'i> {
270270
}
271271
}
272272

273-
impl<'i> fmt::Debug for Span<'i> {
273+
impl fmt::Debug for Span<'_> {
274274
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
275275
f.debug_struct("Span")
276276
.field("str", &self.as_str())
@@ -286,9 +286,9 @@ impl<'i> PartialEq for Span<'i> {
286286
}
287287
}
288288

289-
impl<'i> Eq for Span<'i> {}
289+
impl Eq for Span<'_> {}
290290

291-
impl<'i> Hash for Span<'i> {
291+
impl Hash for Span<'_> {
292292
fn hash<H: Hasher>(&self, state: &mut H) {
293293
(self.input as *const str).hash(state);
294294
self.start.hash(state);

0 commit comments

Comments
 (0)