Search code examples
rustrust-obsolete

How to make Rust compiler resolve import from std?


I'm using the Rust 0.6 compiler for mingw32. I'm able to compile small programs that import from "core", but not from "std". Here is a transcript showing a trivial example and how I am compiling it:

$ cat prog.rs
use std;
$ rustc.exe prog.rs
error: failed to resolve imports
prog.rs:1:4: 1:8 error: unresolved import
prog.rs:1 use std;
              ^~~~
error: aborting due to 2 previous errors

How do I get rustc.exe to resolve the import?


Solution

  • You first need to load the external crate via extern mod std;, and then you can use modules within that crate, or just use them directly qualified by std, e.g.

    extern mod std;
    use std::bigint;
    
    fn main () {
        bigint::BigInt::from_uint(1);
        std::semver::parse("1.2.3-alpha1");
    }
    

    There is more information here.