Rust import packages on repl?
CaptainAnon (150)

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

You are viewing a single comment. View All
jfrank11 (7)

It looks like they are making improvements or it has been possible ever since who knows. But here is how I managed (you might need a paid account for this would be nice if someone with a free account could check):
Open a shell (question mark on the lower right or (Shift-Cmd/Ctrl-S)

> cargo init helloworld
> cd helloworld
> vi Cargo.toml
put `markdown = "0.2"` under `[dependencies]`
> vi src/

enter the following:

extern crate markdown;

fn main() {
    let html : String = markdown::to_html("__I am markdown__");

    println!("{:?}", html);
> cargo run

[email protected]:~/Hello-World/helloworld$ cargo run
   Compiling helloworld v0.1.0 (/home/runner/Hello-World/helloworld)
    Finished dev [unoptimized + debuginfo] target(s) in 3.20s
     Running `target/debug/helloworld`
"<p><strong>I am markdown</strong></p>\n"


joojeene (0)

@jfrank11 that's really useful!
Worked for me except for the
cargo init projectname
where I got this:

> cargo init projectname
error: Failed to create package `projectname` at `

Caused by:
  could not determine the current user, please set $USER

So I had to experiment and had success with:
> USER=runner cargo init projectname

CaptainAnon (150)

@jfrank11 Thanks. That does the trick.