These are chat archives for rust-lang/rust

22nd
Apr 2017
Ravi Teja
@tekjar
Apr 22 2017 10:42
Hi. Why is thread::sleep_ms() deprecated?
Denis Lisov
@tanriol
Apr 22 2017 11:05
@tekjar In favour of thread::sleep(Duration::from_millis(n))
Ravi Teja
@tekjar
Apr 22 2017 11:12
@tanriol Yeah. But the reason? sleep_ms looks simpler
Denis Lisov
@tanriol
Apr 22 2017 11:24
@tekjar Duration is a type specifically intended to be used for time intervals. The _ms suffix looks out of place in Rust, IMO.
mnivoliez
@mnivoliez
Apr 22 2017 11:29
hello. I got a question.

Let say I got a function that takes an array in and return another array of the same number of elements.
I am tempted to write something like that:

fn array_manip(array: &[i32; T]) -> [i32, T]

But this one doesn't seem to work. Any leads on how I could write that?

Denis Lisov
@tanriol
Apr 22 2017 11:32
You cannot do that with fixed-length arrays right now, AFAIK.
mnivoliez
@mnivoliez
Apr 22 2017 11:32
Thank you
Jonas Platte
@jplatte
Apr 22 2017 11:34
Yeah, it's gonna take some time until this is possible, but it's being worked on. You can read about it here: https://internals.rust-lang.org/t/lang-team-minutes-const-generics/5090
Cajetan Puchalski
@CajetanP
Apr 22 2017 12:19
Hey, how do I check whether a char is an ascii character or not ?
Nevermind, I found std::ascii module :p
Sherzod Mutalov
@shmutalov
Apr 22 2017 13:04
:P
fn is_ascii(char_value: char) -> bool {
  let i = char_value as i32;
  i >= 0 && i <= 255
}
Andrey Lesnikov
@ozkriff
Apr 22 2017 13:06
s/255/127/?
Sherzod Mutalov
@shmutalov
Apr 22 2017 13:09
@ozkriff ¯\_(ツ)_/¯
Negative values will not pass btw