Rust注释
Rust注释
任何程序都有注释,并且Rust确实支持以下几个不同的注释:
-
规则注释其由编译器忽略:
- // 行注释,到该行的末尾.
- /* 块注释,直到结束分隔符. */
-
这会被解析成HTML库文档注释:文档:
- /// 下列项目生成文档库.
- //! 生成文档库的封闭项.
fn main() {
// This is an example of a line comment
// Notice how there are two slashes at the beginning of the line
// And that nothing written inside these will be read by the compiler
// println!("Hello, world!");
// Run it. See? Now try deleting the two slashes, and run it again.
/*
* This is another type of comment, the block comment. In general,
* the line comment is the recommended comment style however the
* block comment is extremely useful for debugging
*/
/*
Note, the previous column of `*` was entirely for style. There's
no actual need for it.
*/
// Observe how block comments allow easy expression manipulation
// which line comments do not. Deleting the comment deliminators
// will change the result:
let x = 5 + /* 90 + */ 5;
println!("Is `x` 10 or 100? x = {}", x);
}
可参考:
本站文章除注明转载外,均为本站原创或编译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创优秀实例教程
转载请注明:文章转载自:代码驿站 [http:/www.codeinn.net]
本文标题:Rust注释
本文地址:http://www.codeinn.net/rust/483.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创优秀实例教程
转载请注明:文章转载自:代码驿站 [http:/www.codeinn.net]
本文标题:Rust注释
本文地址:http://www.codeinn.net/rust/483.html

