These are chat archives for rust-lang/rust

Oct 2018
Oct 16 2018 02:18
hi is there a way to have a global hashmap for my program that a bunch of functions can update?
i wanna make a token bucket for my app server
so it'd be userid -> { tokenCount, timestamp } i guess. can i use CAS or something so i dont need locks?
Oct 16 2018 02:38
@jonathansty You could use a some zero sized type as a possible workaround:
There is no memory overhead.
Krzysztof Woś
Oct 16 2018 13:50
Folks, is it appropriate to mention a company that is looking to hire Rust developers here? Seems like a good place to find the right people, but I'm weary of any sort of advertising spoiling technical discussions
Michal 'vorner' Vaner
Oct 16 2018 13:51
Probably fine if there's not too much of it. Also, has a section for Rust jobs.
Krzysztof Woś
Oct 16 2018 13:53
Alright, so here's the shameless plug:
Thanks for the pointer, I'll post something there as well
Victor Moroz
Oct 16 2018 15:21

Can somebody help me with un-boxing:

enum List <'a> {
    Cons(i32, &'a Box<List<'a>>),

use List::{Cons, Nil};

fn main() {
    let nil = Box::new(Nil);
    let l10 = Box::new(Cons(10, &nil));
    if let Cons(n, _) = l10 {
      println!("{:?}", n);

  --> src/
11 |     if let Cons(n, _) = l10 {
   |            ^^^^^^^^^^ expected struct `std::boxed::Box`, found enum `List`
   = note: expected type `std::boxed::Box<List<'_>>`
              found type `List<'_>`

Is there a way to extract Cons (or any other enum) out of Box with stable Rust (I'm aware of box keyword, it's not in stable yet)?

Oct 16 2018 15:32
if let Cons(n, _) = *l10?
Victor Moroz
Oct 16 2018 15:50
@Virtuos86 Thanks! I was sure I tried it, apparently I didn't :( I stumbled on a nested if let (not in this code) where, as I see now, I have to use **tail as the first match Cons(n, tail) returns a reference to Box.
Victor Lopes
Oct 16 2018 20:32
Rustacens, Tokio is still the strong call for async IO or do we have a more interesting option available?