diff --git a/src/punctuated.rs b/src/punctuated.rs index 7880eb29ca..a4278081c4 100644 --- a/src/punctuated.rs +++ b/src/punctuated.rs @@ -187,6 +187,18 @@ impl Punctuated { } } + /// Removes the trailing punctuation from this punctuated sequence, or + /// `None` if there isn't any. + pub fn pop_punct(&mut self) -> Option

{ + if self.last.is_some() { + None + } else { + let (t, p) = self.inner.pop()?; + self.last = Some(Box::new(t)); + Some(p) + } + } + /// Determines whether this punctuated sequence ends with a trailing /// punctuation. pub fn trailing_punct(&self) -> bool {