5. Comment.rs


/// 这种事第二类注释,用于说明本模块的功能。一般置于模块文件的头部。(好像必须放在头部)///
//! note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
//! # The Rust Standard Library
//!
//! The Rust Standard Library provides the essential runtime
//! functionality for building portable Rust software.


第一类是常规注释,这类注释在编译的时候被忽略掉
// 这是第一种注释方式

/* 这是第二种注释方式 */ 

/* 
 * 多行注释
 * 多行注释
 * 多行注释
 */ 




第二类是文档注释,用于通过工具生成HTML API文档
/// 作为说明文档注释的开头:
/// Adds one to the number given. 
/// 
/// # Examples 
/// 
/// ``` 
/// let x = add(1, 2); 
/// 
/// ``` 
fn add(a: i32, b: i32) -> i32 { 
    return a + b; 
} 

fn main() {


}

 

おすすめ

転載: blog.csdn.net/liujiayu2/article/details/114364681