These are chat archives for rust-lang/rust

Jan 2019
Jan 07 08:07
@Genysys I use Rust (rls)
It has nice code competion although I've learned not to rely on it much
Chikirev Sirguy
Jan 07 14:39

pub struct PackBytes;

static mut HANDLERS: Vec<Box<dyn FnMut<&mut PackBytes, Output=()>>> = Vec::new();

fn main() {

    let mut pack = PackBytes;
    unsafe { HANDLERS[0].as_mut().call_mut(&mut pack); }

error[E0597]: `pack` does not live long enough
  --> src\
62 |     unsafe { HANDLERS[0].as_mut().call_mut(&mut pack); }
   |              ------------------------------^^^^^^^^^-
   |              |                             |
   |              |                             borrowed value does not live long enough
   |              argument requires that `pack` is borrowed for `'static`
63 | }
   | - `pack` dropped here while still borrowed
It's looks like the problem with HRTB. Have no idea how to express it.
Tim Robinson
Jan 07 16:49
I thought the type would be Vec<Box<dyn for<'a> FnMut<&'a mut PackBytes, Output=()>>> but I managed to ICE the compiler
Compiles and runs ok if I don't rely on unboxed_closures or fn_traits
Chikirev Sirguy
Jan 07 17:46
thank you for your reply
Michal 'vorner' Vaner
Jan 07 19:55
I'm browsing the Rust teams and I wonder. Are there really teams with multiple leads?
Justin Kilpatrick
Jan 07 23:37
I'm using actix_wend trying to deserialize an octet stream into Json and getting a content type error. Should I do something other than the usual .send().then().json() ? ( I usually deal with appliaction/json content type)
reqwest seems to handle this transparently but I'm trying to async this operation