在 Rust 中,注释必须以两道斜杠开始,并持续到本行的结尾。对于超过一行的注释,需要在每一行前都加上 //,像这样:
// So we’re doing something complicated here, long enough that we need
// multiple lines of comments to do it! Whew! Hopefully, this comment will
// explain what’s going on.
注释也可以在放在包含代码的行的末尾:
let lucky_number = 7; // I’m feeling lucky today
注释位于它所解释的代码行的上面一行:
// I’m feeling lucky today
let lucky_number = 7;
网友评论