Rust import packages on repl?
h
CaptainAnon (150)

I'm currently reading up on rust, and trying to run through some examples on repl.it. I have, however, yet to figure out how to install packages. Does anyone know how to import rust packages (crates) into repl.it.

You are viewing a single comment. View All
Answered by jfrank11 (7) [earned 5 cycles]
View Answer
AndrewBota (1)
  1. Make a new Repl Rust project
  2. In the terminal, type bash
  3. Type cargo new {project name}
  4. You should now see a new folder, navigate to the src file inside it and find the main.rs file. DO NOT CLICK RUN TO RUN YOUR PROGRAM!!! IT WILL ONLY RUN THE ORIGINAL main.rs FILE!
  5. To test run your new Cargo project, type cd {project name} in the terminal, and use command cargo run.
  6. If the run succeeds, open Cargo.toml and add
rand = "{latest version of rand}"
  1. Add use rand::Rng in main.rs
  2. You're good to go!