Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn on_update(&mut self, update: &Update, api: &Api)
- {
- if let UpdateKind::Message(ref message) = update.kind
- {
- if let MessageKind::Text {ref data, ..} = message.kind
- {
- println!("<{}>: {}", &message.from.first_name, data);
- {
- match super::trim_command(self, data)
- {
- Some(trimmed) => {
- let mut splitted = trimmed.split(' ');
- let (time, message_text) = (splitted.next().unwrap(), splitted.next().unwrap());
- let mut ctx = Context::new();
- ctx.var("m", 60.0);
- ctx.var("h", 3600.0);
- match eval_str_with_context(time, ctx)
- {
- Ok(res) => {
- let time_delay = Delay::new(Instant::now().add(Duration::from_secs(res as u64))).from_err();
- let alert_api = api.clone();
- let lol = api.send(message.text_reply("you will be reminded"))
- .join(time_delay)
- .map_err(|_| ())
- .and_then(move |(message, _)| {
- alert_api.send(message.text_reply(message_text));
- Ok(())
- });
- tokio::executor::current_thread::spawn(lol);
- }
- Err(error) => api.spawn(message.text_reply("time parsing error"))
- }
- }
- None => {
- api.spawn(message.text_reply("please provide arguments"))
- }
- }
- };
- }
- }
- error[E0495]: cannot infer an appropriate lifetime for pattern due to conflicting requirements
- --> src/handlers/alert.rs:43:36
- |
- 43 | if let UpdateKind::Message(ref message) = update.kind
- | ^^^^^^^^^^^
- |
- note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 41:5...
- --> src/handlers/alert.rs:41:5
- |
- 41 | / fn on_update(&mut self, update: &Update, api: &Api)
- 42 | | {
- 43 | | if let UpdateKind::Message(ref message) = update.kind
- 44 | | {
- ... |
- 80 | | }
- 81 | | }
- | |_____^
- note: ...so that reference does not outlive borrowed content
- --> src/handlers/alert.rs:43:36
- |
- 43 | if let UpdateKind::Message(ref message) = update.kind
- | ^^^^^^^^^^^
- = note: but, the lifetime must be valid for the static lifetime...
- note: ...so that the type `futures::AndThen<futures::MapErr<futures::Join<telegram_bot_fork::TelegramFuture<telegram_bot_fork::Message>, futures::future::FromErr<tokio_timer::Delay, telegram_bot_fork::Error>>, [closure@src/handlers/alert.rs:64:50: 64:56]>, std::result::Result<(), ()>, [closure@src/handlers/alert.rs:65:51: 68:42 alert_api:telegram_bot_fork::Api, message_text:&str]>` will meet its required lifetime bounds
- --> src/handlers/alert.rs:69:37
- |
- 69 | tokio::executor::current_thread::spawn(lol);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement