- Rust Standard Library Cookbook
- Jan Nils Ferner Daniel Durante
- 214字
- 2021-08-27 19:45:06
How it works...
Calling env::args() returns an iterator over the provided parameters[6]. By convention, the first command-line parameter on most operating systems is the path to the executable itself [12].
We can access specific parameters in two ways: keep them as an iterator [11] or collect them into a collection such as Vec[23]. Don't worry, we are going to talk about them in detail in Chapter 2, Working with Collections. For now, it's enough for you to know that:
Accessing an iterator forces you to check at compile time whether the element exists, for example, an if let binding [12]
Accessing a vector checks the validity at runtime
This means that we could have executed lines [26] and [29] without checking for their validity first in [25] and [28]. Try it yourself, add the &args[3]; line at the end of the program and run it.
- 全國大學(xué)生電子設(shè)計(jì)競賽訓(xùn)練教程
- 數(shù)字電路知識與實(shí)踐課堂
- 移動通信中繼覆蓋系統(tǒng)設(shè)備與工程設(shè)計(jì)
- 數(shù)字平板電視機(jī)維修筆記
- 21堂課精通電子元器件檢測
- 移動基站設(shè)備與維護(hù)(第2版)
- EPON/GPON技術(shù)問答
- 3G UMTS與4G LTE核心網(wǎng)
- 微信公眾平臺與小程序開發(fā):從零搭建整套系統(tǒng)(第2版)
- 軟件創(chuàng)富密碼:iPhone應(yīng)用程序開發(fā)攻略之深入淺出Objective-C 2.0
- Altium Designer 16基礎(chǔ)實(shí)例教程
- 任務(wù)驅(qū)動學(xué)模擬電子技術(shù)
- Final Cut Pro X實(shí)戰(zhàn)從入門到精通
- 光纖通信
- 電子工程師自學(xué)寶典:嵌入設(shè)計(jì)篇