- Rust Quick Start Guide
- Daniel Arbuckle
- 160字
- 2021-06-10 19:46:01
Automatically generated source files
When creating an executable program, cargo adds a file called main.rs to our project as it is created. For a newly created library, it instead adds lib.rs. In either case, that file is the entry point for the whole project.
Let's take a look at the boilerplate main.rs file:
fn main() {
println!("Hello, world!");
}
Simple enough, right? Cargo's default program is a Rust version of the classic hello world program, which has been re-implemented countless times by new programmers in every conceivable programming language.
If we look at a new library's lib.rs file, things are a little more interesting:
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
Instead of having a main function, which all executable programs need because they need a place to start, the library boilerplate includes a framework for automated tests and a single test that confirms that 2 + 2 = 4.
- Software Defined Networking with OpenFlow
- 構建移動網站與APP:HTML 5移動開發入門與實戰(跨平臺移動開發叢書)
- 認識編程:以Python語言講透編程的本質
- Dependency Injection in .NET Core 2.0
- C語言最佳實踐
- 概率成形編碼調制技術理論及應用
- Python貝葉斯分析(第2版)
- 量化金融R語言高級教程
- SQL Server 2016數據庫應用與開發
- Red Hat Enterprise Linux Troubleshooting Guide
- 深度學習入門:基于Python的理論與實現
- 零基礎學Java第2版
- Scala實用指南
- Python自動化開發實戰
- Python服務端測試開發實戰