aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-01 12:06:29 +0200
committeracdenisSK <[email protected]>2017-10-01 12:06:51 +0200
commit7befcd5caa9ccdf44d90ecc12014c335b1bd2be7 (patch)
tree2a6efe6c9655ac5ae2ebd7520e62e1cc0823b475
parentRename an internal Shard Runner method (diff)
downloadserenity-7befcd5caa9ccdf44d90ecc12014c335b1bd2be7.tar.xz
serenity-7befcd5caa9ccdf44d90ecc12014c335b1bd2be7.zip
Have `ConnectionStage` derive Copy
Since it's a fairly simple enum. Also changed `is_connecting` to be more idiomatic.
-rw-r--r--src/gateway/mod.rs10
-rw-r--r--src/gateway/shard.rs2
2 files changed, 6 insertions, 6 deletions
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