DVDAIVO BLOG
A
Tác giả:

hddev244

Bài  2.2 Function trong RUST || Cargo

1 Định nghĩa một function.

fn fcName() {
//something
}

println!("Hello, world!");

+ main là function đặc biệt. luôn luôn chạy đầu tiên khi khởi động.  

+ Thụt lề bằng 4 space chứ không phải tabs

+ println! gọi macro Rust. Thay vào đó, nếu nó gọi một hàm thì nó sẽ được nhập dưới dạng println (không có !).

+ After compiling successfully, Rust outputs a binary executable.

+  

2 Cargo

+ Cargo is Rust’s build system and package manage

+

Listing 1-2: Contents of Cargo.toml generated by cargo new
This file is in the TOML (Tom’s Obvious, Minimal Language) format, which is Cargo’s configuration format.

 

 reading : https://doc.rust-lang.org/book/ch01-03-hello-cargo.html

Cargo has generated a “Hello, world!” program for you, just like the one we wrote in Listing 1-1! So far, the differences between our project and the project Cargo generated are that Cargo placed the code in the src directory and we have a Cargo.toml configuration file in the top directory.