Rust
I'm learning Rust, and I'm going to write about it here what I learn and what I think about it. https://github.com/rytsh/rust00
Check this link for intro https://www.rust-lang.org/learn
- https://doc.rust-lang.org/book/
- https://doc.rust-lang.org/reference/
- https://doc.rust-lang.org/rust-by-example/
- https://doc.rust-lang.org/cargo/index.html
Installation
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shFor update use rustup update.
After that it is adding in your env values in .bashrc. Need to refresh your terminal.
01 - Hello World
fn main() {
println!("Hello, world!");
}Create executable file with this command:
# generate executable file with name hello
rustc hello.rsExtension of Rust files is .rs.
For generating Obj file
# generate obj file with name hello.o
rustc --emit=obj hello.rsCargo New Package
cargo new hello_cargoThis will create a new directory with the name hello_cargo and a new Rust package inside it.
cd hello_cargoRun cargo build
cargo buildIt is creating under the target/debug directory.
Use cargo build --release for release build.
--bin is for binary and --lib is for library use when creating new package.
cargo new hello_bin --bin
cargo new hello_lib --libDefault work like --bin.
Clear artifacts with cargo clean.
u128
Rust has 128 bit signed and unsigned integers.