These are chat archives for rust-lang/rust

7th
Jan 2019
Zakarum
@omni-viral
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
@cheblin
Jan 07 14:39
#![feature(unboxed_closures)]
#![feature(const_vec_new)]
#![feature(fn_traits)]

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\main.rs:62:44
   |
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
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c0359753acbe472cd86915960965a088
It's looks like the problem with HRTB. Have no idea how to express it.
Tim Robinson
@1tgr
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
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=67b8d71e27cf1f81c06c81b46eddeaf1
Chikirev Sirguy
@cheblin
Jan 07 17:46
thank you for your reply
Michal 'vorner' Vaner
@vorner
Jan 07 19:55
I'm browsing the Rust teams and I wonder. Are there really teams with multiple leads?
Justin Kilpatrick
@jkilpatr
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