@@ -329,6 +329,24 @@ pub enum PopError {
329
329
Closed ,
330
330
}
331
331
332
+ impl PopError {
333
+ /// Returns `true` if the queue is empty.
334
+ pub fn is_empty ( & self ) -> bool {
335
+ match self {
336
+ PopError :: Empty => true ,
337
+ PopError :: Closed => false ,
338
+ }
339
+ }
340
+
341
+ /// Returns `true` if the queue is empty and closed.
342
+ pub fn is_closed ( & self ) -> bool {
343
+ match self {
344
+ PopError :: Empty => false ,
345
+ PopError :: Closed => true ,
346
+ }
347
+ }
348
+ }
349
+
332
350
impl error:: Error for PopError { }
333
351
334
352
impl fmt:: Debug for PopError {
@@ -359,6 +377,32 @@ pub enum PushError<T> {
359
377
Closed ( T ) ,
360
378
}
361
379
380
+ impl < T > PushError < T > {
381
+ /// Unwraps the item that couldn't be pushed.
382
+ pub fn into_inner ( self ) -> T {
383
+ match self {
384
+ PushError :: Full ( t) => t,
385
+ PushError :: Closed ( t) => t,
386
+ }
387
+ }
388
+
389
+ /// Returns `true` if the queue is full.
390
+ pub fn is_full ( & self ) -> bool {
391
+ match self {
392
+ PushError :: Full ( _) => true ,
393
+ PushError :: Closed ( _) => false ,
394
+ }
395
+ }
396
+
397
+ /// Returns `true` if the queue is closed.
398
+ pub fn is_closed ( & self ) -> bool {
399
+ match self {
400
+ PushError :: Full ( _) => false ,
401
+ PushError :: Closed ( _) => true ,
402
+ }
403
+ }
404
+ }
405
+
362
406
impl < T : fmt:: Debug > error:: Error for PushError < T > { }
363
407
364
408
impl < T : fmt:: Debug > fmt:: Debug for PushError < T > {
0 commit comments