- Rust's standard library provides common functionality, similar to C's standard library (
libc
).
- Includes data structures like
Vec
, HashMap
, and utilities for I/O, threading, and more.
- Rust has built-in support for unit tests using the
#[test]
attribute.
#[cfg(test)]
mod tests {
#[test]
fn test_add() {
assert_eq!(2 + 2, 4);
}
}
- Building:
cargo build
- Running:
cargo run
- Testing:
cargo test
- Documentation:
cargo doc --open
- Rust provides detailed compiler error messages to help you fix issues.
- Tools like
rustc
(the compiler) and clippy
(a linter) assist in writing idiomatic Rust code.