Adding time and rand crates for Rust

It seems that “extern crate time;” aborts again. :disappointed:
Has there been any changes in here or I made some mistakes?

I got this error when I trying to use the ‘rand’

  error[E0463]: can't find crate for `rand`
     --> /tmp/Answer.rs:6:1
      |
    6 | extern crate rand;
      | ^^^^^^^^^^^^^^^^^^ can't find crate

    error: aborting due to previous error

Oh no :frowning: . We’ve upgraded Rust recently… Sorry for the inconvenience! I didn’t see your message until now, I’ll have a look to it tomorrow.

@Coac @geot it should be fixed (at least for the challenge)

Thank you :slight_smile:

Thanks for the quick solution! :slight_smile:

Hello,

Could it be possible to update the FAQ in order to add the information that rand and time are available ?

1 Like

Would you be willing to also add the itertools crate? It provides functionality similar to itertools in Python and really helps with some basic things. For example in Python you can split a string s (for example the input string) as follows:

a, b, c, d = s.split()

With itertools in Rust, you can write something similar.

use itertools::Itertools;

let (a, b, c, d) = s.split_whitespace().next_tuple.unwrap();

(Although, I can think of other ways to code this example as well without the crate, so it is not the end of the world if it can’t be added.)

@_CG_Maxime I do have this error again while using crate rand perhaps due to the recent langage update:

error[E0463]: can't find crate for `rand`
 --> /tmp/Answer.rs:1:1
  |
1 | extern crate rand;
  | ^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

Could you fix it please?
Thx
Guillaume

Hello,

This is fixed. Please check this is working as expected now.

3 Likes

Lo,
It works many thanks :slight_smile:

Is there any way to know what crates are available for us to use? rand and time are great. Anything else?

1 Like

Would it be possible to add lazy_static? IMO this is basic functionality as C++ and Java have it built in.

1 Like

available in the faq (/faq)

image

about lazy_static, I don’t know. I’ll check.

I think time is not needed any more. The original proposal was from before the release of Rust 1.8.0, which introduced std::time::Instant and std::time::SystemTime.
I agree that lazy_static would be quite useful to introduce.

And everything else should be updated. I have recently had to work around a couple functions (such as Iterator::step_by) not yet existing in 1.27.