@@ -353,16 +353,12 @@ impl AsyncBufRead for ReadRtt {
353
353
354
354
loop {
355
355
match & mut this. st {
356
- ReadRttSt :: Idle { pos, len, .. } => {
357
- if * pos == * len {
356
+ & mut ReadRttSt :: Idle { pos, len, .. } => {
357
+ if pos == len {
358
358
// Buffer is empty; start reading RTT channels
359
- let ( mut buf, mut rtt, mut session) =
360
- match replace ( & mut this. st , ReadRttSt :: Invalid ) {
361
- ReadRttSt :: Idle {
362
- buf, rtt, session, ..
363
- } => ( buf, rtt, session) ,
364
- _ => unreachable ! ( ) ,
365
- } ;
359
+ let ReadRttSt :: Idle { mut buf, mut rtt, mut session, .. } =
360
+ replace ( & mut this. st , ReadRttSt :: Invalid )
361
+ else { unreachable ! ( ) } ;
366
362
367
363
let halt_on_access = this. options . halt_on_access ;
368
364
@@ -386,11 +382,8 @@ impl AsyncBufRead for ReadRtt {
386
382
//
387
383
// Borrow `this.st` again, this time using the full
388
384
// lifetime of `self`.
389
- if let ReadRttSt :: Idle { buf, pos, len, .. } = & this. st {
390
- return Poll :: Ready ( Ok ( & buf[ ..* len] [ * pos..] ) ) ;
391
- } else {
392
- unreachable ! ( )
393
- }
385
+ let ReadRttSt :: Idle { buf, .. } = & this. st else { unreachable ! ( ) } ;
386
+ return Poll :: Ready ( Ok ( & buf[ ..len] [ pos..] ) ) ;
394
387
}
395
388
}
396
389
@@ -423,12 +416,9 @@ impl AsyncBufRead for ReadRtt {
423
416
ReadRttSt :: PollDelay { delay, .. } => {
424
417
ready ! ( delay. as_mut( ) . poll( cx) ) ;
425
418
426
- let ( buf, rtt, session) = match replace ( & mut this. st , ReadRttSt :: Invalid ) {
427
- ReadRttSt :: PollDelay {
428
- buf, rtt, session, ..
429
- } => ( buf, rtt, session) ,
430
- _ => unreachable ! ( ) ,
431
- } ;
419
+ let ReadRttSt :: PollDelay { buf, rtt, session, .. } =
420
+ replace ( & mut this. st , ReadRttSt :: Invalid )
421
+ else { unreachable ! ( ) } ;
432
422
433
423
this. st = ReadRttSt :: Idle {
434
424
buf,
@@ -445,13 +435,9 @@ impl AsyncBufRead for ReadRtt {
445
435
}
446
436
447
437
fn consume ( mut self : Pin < & mut Self > , amt : usize ) {
448
- match & mut self . st {
449
- ReadRttSt :: Idle { pos, len, .. } => {
450
- * pos += amt;
451
- assert ! ( * pos <= * len) ;
452
- }
453
- _ => unreachable ! ( ) ,
454
- }
438
+ let ReadRttSt :: Idle { pos, len, .. } = & mut self . st else { unreachable ! ( ) } ;
439
+ * pos += amt;
440
+ assert ! ( * pos <= * len) ;
455
441
}
456
442
}
457
443
0 commit comments