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

Specifying the argument types

As with much of the string handling in the C family of languages, it is possible to create a string based on a format string (for example, {0:##.###} would give a formatted output of the form xy.abc).

Similar things can be done in Rust, as follows:

let my_number = format!("{:.3}", 3.1415927); 

In the format string, the colon says we're requesting formatting for the value. Dot and 3 says that we want the number formatted to three decimal points. The formatter rounds the value for us, so the output will be 3.142.

主站蜘蛛池模板: 泌阳县| 沂源县| 巧家县| 姜堰市| 白水县| 抚宁县| 青阳县| 商丘市| 六安市| 阜新| 浦江县| 广安市| 银川市| 汽车| 保德县| 萝北县| 新泰市| 新泰市| 凌海市| 闸北区| 福安市| 延津县| 嘉善县| 平顺县| 嘉峪关市| 仪征市| 扶风县| 威海市| 运城市| 石家庄市| 周至县| 江山市| 呼图壁县| 正蓝旗| 中方县| 木兰县| 谢通门县| 防城港市| 容城县| 天长市| 大埔县|