- 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!(" {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.
推薦閱讀
- PHP動態網站程序設計
- Java范例大全
- Java 開發從入門到精通(第2版)
- Visual Basic 6.0程序設計計算機組裝與維修
- 樂學Web編程:網站制作不神秘
- Visual Basic學習手冊
- 軟件測試技術指南
- Java編程的邏輯
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- Django實戰:Python Web典型模塊與項目開發
- Apache Camel Developer's Cookbook
- 創意UI Photoshop玩轉移動UI設計
- Python編程快速上手2
- FusionCharts Beginner’s Guide:The Official Guide for FusionCharts Suite
- LabVIEW數據采集(第2版)