As I usually do when installing new languages, I looked for a version manager for Rust.
Rust has a rather nice one, called
rustup, which lets you switch from nightly to stable, and to different targets with very little effort.
If you are on a Mac or Linux machine, this should do it:
curl https://sh.rustup.rs -sSf | sh
Now you hopefully have RustUp, one thing you should know is there are three versions of Rust you can use with
rustup install <version>will install the one you want
rustup default stablewill set the one you can access by default to be the stable one.
Now you should have
$ rustc --version rustc 1.9.0 (e4e8b6668 2016-05-18)
If you want a very specific version in a specific directory, you can:
$ cd <projectdir> $ rustup override <version>
$ rustup override add nightly-2014-12-18 $ rustup override add 1.0.0
You can check if there are overrides with
rustup show and remove them with
rustup override remove.
You can also temporarily use a specific version just for one command, by prepending
rustup run <version> <command>:
$ rustup run beta bash
will open a beta shell.
Keeping up to date
$ rustup update
will update all your rust installs.
cargo install racer for better completion.
You'll also need to clone the rust source code from git in some directory, then set
RUST_SRC_PATH to that directory.
To test it actually works, try:
$ racer complete std::io::B MATCH BufReader,48,11,/Users/<user>/.rust/rust/src/libstd/io/buffered.rs,Struct,pub struct BufReader<R> ...
I use terminal emacs and
rust-mode works like a charm.
You'll need to install
What I have in my
(add-hook 'rust-mode-hook #'racer-mode) (add-hook 'racer-mode-hook #'eldoc-mode) (add-hook 'racer-mode-hook #'company-mode) (add-hook 'rust-mode-hook '(lambda () (add-hook 'flycheck-mode-hook #'flycheck-rust-setup) (local-set-key (kbd "TAB") #'company-indent-or-complete-common))) (setq racer-rust-src-path (getenv "RUST_SRC_PATH")) (global-set-key (kbd "TAB") #'company-indent-or-complete-common) ; (setq company-tooltip-align-annotations t)
rustup, the successor of
multirust can also manage multiple and custom toolchains for cross-compilation.
$ rustup target list
to get a list of the available targets.
More info in the docs.
If you have multirust installed, you might have to wipe it out completely before RustUp works.
So now you should have a pretty nice dev env for Rust (assuming you like emacs).
Comments? Give me a shout at @shadercat.
To get the latest post updates subscribe to the ShaderCat newsletter.
You can support my writing on ShaderCat's Patreon.