@@ -162,7 +162,12 @@ impl<T, P> Punctuated<T, P> {
162
162
/// Panics if the sequence does not already have a trailing punctuation when
163
163
/// this method is called.
164
164
pub fn push_value ( & mut self , value : T ) {
165
- assert ! ( self . empty_or_trailing( ) ) ;
165
+ assert ! (
166
+ self . empty_or_trailing( ) ,
167
+ "Punctuated::push_value: Punctuated is not empty or \
168
+ does not have a trailing punctuation"
169
+ ) ;
170
+
166
171
self . last = Some ( Box :: new ( value) ) ;
167
172
}
168
173
@@ -174,7 +179,10 @@ impl<T, P> Punctuated<T, P> {
174
179
///
175
180
/// Panics if the sequence is empty or already has a trailing punctuation.
176
181
pub fn push_punct ( & mut self , punctuation : P ) {
177
- assert ! ( self . last. is_some( ) ) ;
182
+ assert ! (
183
+ self . last. is_some( ) ,
184
+ "Punctuated::push_punct: Punctuated doesn't have any items"
185
+ ) ;
178
186
let last = self . last . take ( ) . unwrap ( ) ;
179
187
self . inner . push ( ( * last, punctuation) ) ;
180
188
}
@@ -228,7 +236,10 @@ impl<T, P> Punctuated<T, P> {
228
236
where
229
237
P : Default ,
230
238
{
231
- assert ! ( index <= self . len( ) ) ;
239
+ assert ! (
240
+ index <= self . len( ) ,
241
+ "Punctuated::insert: index out of range"
242
+ ) ;
232
243
233
244
if index == self . len ( ) {
234
245
self . push ( value) ;
@@ -454,7 +465,12 @@ impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P> {
454
465
455
466
impl < T , P > Extend < Pair < T , P > > for Punctuated < T , P > {
456
467
fn extend < I : IntoIterator < Item = Pair < T , P > > > ( & mut self , i : I ) {
457
- assert ! ( self . empty_or_trailing( ) ) ;
468
+ assert ! (
469
+ self . empty_or_trailing( ) ,
470
+ "Punctuated::extend: Punctuated is not empty or \
471
+ does not have a trailing punctuation"
472
+ ) ;
473
+
458
474
let mut nomore = false ;
459
475
for pair in i {
460
476
if nomore {
0 commit comments