Access
Credentials:
- User:
ferris - Password: (stored in
/root/.cloudzy-creds)
SSH in op de server als root en schakel dan over naar de Rust gebruiker:
su - ferris
Important Directories
/home/ferris/.cargo/→ Cargo binaries (cargo, installed crates)/home/ferris/.rustup/→ Rust toolchains en componenten/home/ferris/→ Jouw werkruimte (projecten staan hier)
Useful Commands
Verify installation:
cargo --version
rustc --version
Update Rust:
rustup update
Extra tools toevoegen/bijwerken (bijv. linter):
rustup component add clippy
Uninstall Rust:
rustup self uninstall
Jouw project bouwen:
cargo build
Jouw project uitvoeren:
cargo run
Run tests:
cargo test
Documentatie bouwen voor jouw project:
cargo doc --open
Een bibliotheek publiceren naar crates.io:
cargo publish
Een eenvoudige Rust applicatie
Een nieuw project aanmaken:
cargo new hello-rust
cd hello-rust
Het standaardprogramma uitvoeren:
cargo run
Een afhankelijkheid toevoegen via CLI:
cargo add ferris-says
Dan bouwen (Cargo installeert onze afhankelijkheid automatisch):
cargo build
Dit genereert ook Cargo.lock (lockfile met versies van afhankelijkheden).
Edit src/main.rs:
use ferris_says::say;
use std::io::{stdout, BufWriter};
fn main() {
let stdout = stdout();
let message = String::from("Hello fellow Rustaceans!");
let width = message.chars().count();
let mut writer = BufWriter::new(stdout.lock());
say(&message, width, &mut writer).unwrap();
}
Run it:
cargo run