官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 乌海市| 大埔县| 大石桥市| 游戏| 渭南市| 鹤壁市| 东海县| 新河县| 锦屏县| 临安市| 资中县| 乌拉特前旗| 千阳县| 横峰县| 巴中市| 勃利县| 炉霍县| 连南| 射阳县| 光山县| 丘北县| 青河县| 西乌珠穆沁旗| 钟山县| 拉萨市| 高邮市| 晋江市| 集安市| 宁南县| 泾川县| 务川| 汉阴县| 乐业县| 临桂县| 团风县| 阜南县| 济阳县| 英吉沙县| 电白县| 福安市| 阜平县|