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

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.

主站蜘蛛池模板: 潮州市| 壶关县| 永兴县| 宜兰县| 四子王旗| 湖北省| 宁明县| 普兰县| 兴宁市| 垦利县| 基隆市| 陆丰市| 湟源县| 富平县| 濮阳县| 山阴县| 沂南县| 岚皋县| 遵义县| 六安市| 静宁县| 永泰县| 临夏县| 太和县| 成都市| 清新县| 阜康市| 株洲市| 达州市| 原平市| 衡南县| 萝北县| 辰溪县| 富平县| 内江市| 区。| 绥江县| 白朗县| 中山市| 新丰县| 兴隆县|