织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

欧博官网How to document Rust function arguments?

时间:2025-08-24 20:33来源: 作者:admin 点击: 2 次
According to the rust documentation, function docs are formatted like this: #![crate_name = "doc"] /// A human being is represented here pu

According to the rust documentation, function docs are formatted like this:

#![crate_name = "doc"] /// A human being is represented here pub struct Person { /// A person must have a name, no matter how much Juliet may hate it name: String, } impl Person { /// Returns a person with the name given them /// /// # Arguments /// /// * `name` - A string slice that holds the name of the person /// /// # Examples /// /// ``` /// // You can have rust code between fences inside the comments /// // If you pass --test to `rustdoc`, it will even test it for you! /// use doc::Person; /// let person = Person::new("name"); /// ``` pub fn new(name: &str) -> Person { Person { name: name.to_string(), } } /// Gives a friendly hello! /// /// Says "Hello, [name]" to the `Person` it is called on. pub fn hello(& self) { println!("Hello, {}!", self.name); } } fn main() { let john = Person::new("John"); john.hello(); }

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-08-25 11:08 最后登录:2025-08-25 11:08
栏目列表
推荐内容