Skip to content

Commit

Permalink
refactor(model): simplify closecode::can_reconnect (twilight-rs#2158)
Browse files Browse the repository at this point in the history
Simplify the implementation of `CloseCode::can_reconnect` to be a
`matches!` statement instead of a `match` statement returning a boolean.
  • Loading branch information
zeylahellyer authored Feb 20, 2023
1 parent 808391c commit 9117589
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions twilight-model/src/gateway/close_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,17 @@ impl CloseCode {
/// Refer to the type-level documentation for Discord's table on close codes
/// that can be reconnected.
pub const fn can_reconnect(self) -> bool {
match self {
matches!(
self,
Self::UnknownError
| Self::UnknownOpcode
| Self::DecodeError
| Self::NotAuthenticated
| Self::AlreadyAuthenticated
| Self::InvalidSequence
| Self::RateLimited
| Self::SessionTimedOut => true,
Self::AuthenticationFailed
| Self::InvalidShard
| Self::ShardingRequired
| Self::InvalidApiVersion
| Self::InvalidIntents
| Self::DisallowedIntents => false,
}
| Self::UnknownOpcode
| Self::DecodeError
| Self::NotAuthenticated
| Self::AlreadyAuthenticated
| Self::InvalidSequence
| Self::RateLimited
| Self::SessionTimedOut
)
}
}

Expand Down

0 comments on commit 9117589

Please sign in to comment.