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

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.

主站蜘蛛池模板: 成武县| 陇西县| 永登县| 镇安县| 佛冈县| 运城市| 安庆市| 浙江省| 昌江| 英山县| 沛县| 蒙阴县| 嘉峪关市| 德惠市| 宝丰县| 治多县| 闵行区| 桦川县| 丰顺县| 万载县| 修武县| 花垣县| 卓资县| 翼城县| 秀山| 施秉县| 绵阳市| 娄烦县| 斗六市| 凭祥市| 瑞昌市| 镇赉县| 重庆市| 淮滨县| 平昌县| 洪雅县| 习水县| 舒城县| 潼关县| 新龙县| 张家港市|