- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 119字
- 2021-07-02 23:07:20
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.
推薦閱讀
- Puppet 4 Essentials(Second Edition)
- Java Web開發(fā)學(xué)習(xí)手冊
- 樂高機器人設(shè)計技巧:EV3結(jié)構(gòu)設(shè)計與編程指導(dǎo)
- 精通軟件性能測試與LoadRunner實戰(zhàn)(第2版)
- INSTANT Django 1.5 Application Development Starter
- Python算法從菜鳥到達(dá)人
- Unity 2018 Shaders and Effects Cookbook
- R用戶Python學(xué)習(xí)指南:數(shù)據(jù)科學(xué)方法
- Oracle實用教程
- Vue.js光速入門及企業(yè)項目開發(fā)實戰(zhàn)
- Hacking Android
- 安卓工程師教你玩轉(zhuǎn)Android
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發(fā)技術(shù)
- INSTANT LESS CSS Preprocessor How-to