diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/connection.rs | 24 | ||||
| -rw-r--r-- | src/lib.rs | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/client/connection.rs b/src/client/connection.rs index fd06160..1ba3341 100644 --- a/src/client/connection.rs +++ b/src/client/connection.rs @@ -456,6 +456,30 @@ impl Connection { } } +impl Drop for Connection { + fn drop(&mut self) { + match self.shutdown() { + Ok(()) => { + if let Some([shard, shards]) = self.shard_info { + println!("Correctly shutdown shard {}/{}", shard, shards - 1); + } else { + println!("Correctly shutdown connection"); + } + }, + Err(why) => { + if let Some([shard, shards]) = self.shard_info { + println!("Failed to shutdown shard {}/{}: {:?}", + shard, + shards - 1, + why); + } else { + println!("Failed to shutdown connection: {:?}", why); + } + } + } + } +} + trait ReceiverExt { fn recv_json<F, T>(&mut self, decode: F) -> Result<T> where F: FnOnce(Value) -> Result<T>; @@ -76,6 +76,7 @@ //! [state docs]: ext/state/index.html #![allow(doc_markdown, unknown_lints)] #![allow(dead_code)] +#![feature(slice_patterns)] #[macro_use] extern crate bitflags; |