dtolnay / syn

Parser for Rust source code
Apache License 2.0
2.82k stars 308 forks source link

Punctuated::pop should return Option<T>, not Option<Pair<T, P>> #1600

Open dtolnay opened 5 months ago

dtolnay commented 5 months ago

first(), last(), iter() also do not produce Pair. We make you explicitly ask for Pair by writing pairs() or pairs().next() or pairs().next_back(), since wanting the whole Pair is uncommon.

pop() should change as follows:

  impl<T, P> Punctuated<T, P> {
-     pub fn pop(&mut self) -> Option<Pair<T, P>>;
+     pub fn pop(&mut self) -> Option<T>;
+     pub fn pop_pair(&mut self) -> Option<Pair<T, P>>;  // (?)
  }