- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 123字
- 2021-07-02 23:07:21
Named parameters
As shown in the formatting table, it is possible to use a named parameter. The operation of these is similar to a positional parameter; the difference, though, is that a named parameter is used. This is very useful in ensuring that the value output in the string is the correct parameter.
It is perfectly acceptable to use an empty parameter within a formatted string when using a named parameter, for example:
format!("{b} {a} {} {t}", b = "B", a = 'a', t = 33);
The rules for handling non-positional parameters alongside named parameters are similar to the rules for positional parameters: the named parameters are ignored when figuring out the positions. This will, therefore, give the output B a B 33.
推薦閱讀
- C語言程序設計教程
- Python for Secret Agents:Volume II
- 區塊鏈架構與實現:Cosmos詳解
- Visual Basic程序設計習題解答與上機指導
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- 基于Struts、Hibernate、Spring架構的Web應用開發
- WordPress 4.0 Site Blueprints(Second Edition)
- 51單片機C語言開發教程
- JavaScript程序設計(第2版)
- 汽車人機交互界面整合設計
- 網絡數據采集技術:Java網絡爬蟲實戰
- Maven for Eclipse
- Python編程基礎教程
- Selenium WebDriver Practical Guide
- Visual C++程序設計全程指南