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

The difference between println! and println

Up to this point, we've used println! for outputting text. This is fine, but consider what println! does. Whenever you see a ! mark, it symbolizes a macro. Macros are used when some part of the function needs to be executed at compile time, rather than at runtime.

Consider the following:

println!("{}", a); 
Console.WriteLine("{0}", a); 

In C#, the preceding snippet will output a line with the value of a on the line. In this case, a can be of any type that supports conversion to a formatted output. The same applies to Rust. A line is output with the value of a.

The println! macro is actually implemented in the Rust standard library.

主站蜘蛛池模板: 兴业县| 武定县| 乌拉特后旗| 平舆县| 府谷县| 威远县| 上思县| 柳州市| 汶上县| 彩票| 裕民县| 剑阁县| 宜都市| 东乌珠穆沁旗| 马鞍山市| 乐平市| 巍山| 南通市| 南康市| 剑川县| 彰化市| 通山县| 双柏县| 满城县| 资溪县| 兴海县| 东乌珠穆沁旗| 宁都县| 成武县| 通江县| 正宁县| 壶关县| 虹口区| 光山县| 漯河市| 团风县| 陆丰市| 公安县| 闽侯县| 乾安县| 上犹县|