Created
November 21, 2015 23:02
-
-
Save dten/c1d9c6503d6aa1973b91 to your computer and use it in GitHub Desktop.
Example of simple slow build for slack-rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate slack; | |
extern crate rustc_serialize; | |
use rustc_serialize::json; | |
use slack::api::*; | |
struct MyHandler { | |
count: i64, | |
} | |
#[allow(unused_variables)] | |
impl slack::EventHandler for MyHandler { | |
fn on_receive(&mut self, cli: &mut slack::RtmClient, json_str: &str) { | |
self.count += 1; | |
// Below line makes cargo build --release go from 5 seconds to 66 (after intial really slow one) | |
json::decode::<MessageEvent>(json_str); | |
} | |
fn on_ping(&mut self, cli: &mut slack::RtmClient) { } | |
fn on_close(&mut self, cli: &mut slack::RtmClient) { } | |
fn on_connect(&mut self, cli: &mut slack::RtmClient) { } | |
} | |
fn main() { | |
let mut handler = MyHandler { count: 0 }; | |
let mut cli = slack::RtmClient::new("blah-blah-blah"); | |
let _ = cli.login_and_run::<MyHandler>(&mut handler); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment