From 7befcd5caa9ccdf44d90ecc12014c335b1bd2be7 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Sun, 1 Oct 2017 12:06:29 +0200 Subject: Have `ConnectionStage` derive Copy Since it's a fairly simple enum. Also changed `is_connecting` to be more idiomatic. --- src/gateway/mod.rs | 10 +++++----- src/gateway/shard.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs index bd9c45b..b593f5c 100644 --- a/src/gateway/mod.rs +++ b/src/gateway/mod.rs @@ -60,7 +60,7 @@ pub use self::shard::Shard; /// This can be useful for knowing which shards are currently "down"/"up". /// /// [`Shard`]: struct.Shard.html -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] pub enum ConnectionStage { /// Indicator that the [`Shard`] is normally connected and is not in, e.g., /// a resume phase. @@ -130,9 +130,9 @@ impl ConnectionStage { pub fn is_connecting(&self) -> bool { use self::ConnectionStage::*; - *self == Connecting - || *self == Handshake - || *self == Identifying - || *self == Resuming + match *self { + Connecting | Handshake | Identifying | Resuming => true, + _ => false, + } } } diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index de5104e..b0d10a1 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -306,7 +306,7 @@ impl Shard { /// Returns the current connection stage of the shard. pub fn stage(&self) -> ConnectionStage { - self.stage.clone() + self.stage } /// Handles an event from the gateway over the receiver, requiring the -- cgit v1.2.3