These are chat archives for rust-lang/rust

3rd
Jul 2017
Jonas Platte
@jplatte
Jul 03 2017 02:56
@stevensonmt Yes, that is the issue. You have declared your HashMap to contain &'static strs, that is string slices with application lifetime. However, employee and department are Strings that are only valid inside of this function, and so are the slices you extract from them.
You should probably change it to HashMap<String, String>.
Or, if most of your keys and/or values are actually baked into your application and only very few actually require being owned by the HashMap, you could use Cow<str> instead of String (but that is an optimization that you probably don't need)
stevensonmt
@stevensonmt
Jul 03 2017 03:03
Yeah, this is not any kind of production thing. Just working my way through TRPL and this is one of exercises suggested at the end of chapter 8. All of the data will be input by user into this HashMap.
Zakarum
@omni-viral
Jul 03 2017 11:05
Can I be notified somehow when furures::Future gets ready?
With possible false positives
Joonas Koivunen
@koivunej
Jul 03 2017 13:48
@omni-viral i'm not an authoritive source on futures-rs but I think that's not possible supported as an built-in feature. you can get notifications if you implement those yourself but then you could probably just call future.wait()
Denis Lisov
@tanriol
Jul 03 2017 13:55
@omni-viral Is your code running async with an event loop or synchronously without one?
Zakarum
@omni-viral
Jul 03 2017 13:59
@koivunej I can't wait for future to be ready, I have other things to compute. I just don't want polling too much
@tanriol Futures come from different sources. Some of them are from network layer which has event loop ofc
Joonas Koivunen
@koivunej
Jul 03 2017 14:24
@omni-viral if you are using tokio-core this method might be of interest: https://docs.rs/tokio-core/0.1.8/tokio_core/reactor/struct.Core.html#method.turn
stevensonmt
@stevensonmt
Jul 03 2017 16:32
Is it not possible to make the rust playground allow input from stdin using io::stdin().read_line()?
Jonas Platte
@jplatte
Jul 03 2017 16:44
@stevensonmt It's probably not that it's impossible, but rather just that nobody has implemented it yet.
stevensonmt
@stevensonmt
Jul 03 2017 16:45
ok, thanks. and yeah, I meant possible as in "currently available".
Jonas Platte
@jplatte
Jul 03 2017 16:46
@stevensonmt Oh sorry, for some reason I thought you were asking why it wasn't possible
But yeah, I guess I still kind of answered your question. AFAIK, it's not possible.
Denis Lisov
@tanriol
Jul 03 2017 16:51
I'd guess one reason may be related to the possibility of DoS. Currently play has a timeout of about 5 seconds, which will likely be unsufficient... and processes waiting on stdin will increase server memory consumption.
stevensonmt
@stevensonmt
Jul 03 2017 17:09
makes sense
it still compiles so I think I can continue to use it for troubleshooting regardless.