From 38d99a7f8cbc1cceb06eab8378348a988561c84e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 4 Mar 2021 17:47:01 -0800 Subject: [PATCH] Touch up assertion messages from PR 970 --- src/punctuated.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/punctuated.rs b/src/punctuated.rs index 299548c68c..f94edc2915 100644 --- a/src/punctuated.rs +++ b/src/punctuated.rs @@ -164,7 +164,7 @@ impl Punctuated { pub fn push_value(&mut self, value: T) { assert!( self.empty_or_trailing(), - "Punctuated::push_value: Punctuated is not empty or does not have a trailing punctuation", + "Punctuated::push_value: cannot push value if Punctuated is missing trailing punctuation", ); self.last = Some(Box::new(value)); @@ -180,8 +180,9 @@ impl Punctuated { pub fn push_punct(&mut self, punctuation: P) { assert!( self.last.is_some(), - "Punctuated::push_punct: Punctuated doesn't have any items", + "Punctuated::push_punct: cannot push punctuation if Punctuated is empty or already has trailing punctuation", ); + let last = self.last.take().unwrap(); self.inner.push((*last, punctuation)); }