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

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.

主站蜘蛛池模板: 保亭| 陕西省| 茂名市| 秀山| 赤峰市| 开原市| 双峰县| 彭山县| 岳普湖县| 太仓市| 长宁区| 西丰县| 陈巴尔虎旗| 平定县| 抚远县| 阿图什市| 洛扎县| 合作市| 湄潭县| 淳安县| 雷山县| 增城市| 和静县| 郸城县| 砀山县| 称多县| 子洲县| 清原| 友谊县| 西青区| 盈江县| 桃源县| 理塘县| 正宁县| 河池市| 南溪县| 岳阳县| 黄浦区| 通城县| 偃师市| 甘南县|