syn icon indicating copy to clipboard operation
syn copied to clipboard

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

Open dtolnay opened this issue 1 year ago • 0 comments

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>>;  // (?)
  }

dtolnay avatar Mar 22 '24 21:03 dtolnay