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

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.

主站蜘蛛池模板: 广宗县| 工布江达县| 无为县| 玛沁县| 静海县| 定兴县| 长兴县| 嘉义县| 新田县| 朔州市| 荣昌县| 专栏| 邮箱| 大理市| 白银市| 新乡县| 邹城市| 大理市| 辛集市| 丰原市| 当雄县| 香港 | 孝义市| 兴宁市| 屏东县| 新野县| 旺苍县| 左云县| 普宁市| 新郑市| 翼城县| 沙河市| 白朗县| 天津市| 南雄市| 宾川县| 海林市| 中阳县| 蒲江县| 顺义区| 辉南县|