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

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.

主站蜘蛛池模板: 堆龙德庆县| 肇东市| 关岭| 紫阳县| 砀山县| 印江| 郁南县| 桦甸市| 永定县| 霍州市| 调兵山市| 洛隆县| 武义县| 德惠市| 乌拉特前旗| 盈江县| 遂溪县| 阳谷县| 榕江县| 勃利县| 平乡县| 乌什县| 嘉义县| 宿松县| 通山县| 泸溪县| 民权县| 怀远县| 富裕县| 周口市| 汝阳县| 安丘市| 扎赉特旗| 澄江县| 蓝田县| 凉城县| 平罗县| 封丘县| 乐业县| 太仆寺旗| 中西区|