<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 注釋 > [comments.md](https://github.com/rust-lang/rust/blob/master/src/doc/book/comments.md) commit 024aa9a345e92aa1926517c4d9b16bd83e74c10d 現在我們寫了一些函數,是時候學習一下注釋了。注釋是你幫助其他程序員理解你的代碼的備注。編譯器基本上會忽略它們。 Rust有兩種需要你了解的注釋格式:*行注釋*(*line comments*)和*文檔注釋*(*doc comments*)。 ~~~ // Line comments are anything after ‘//’ and extend to the end of the line. let x = 5; // this is also a line comment. // If you have a long explanation for something, you can put line comments next // to each other. Put a space between the // and your comment so that it’s // more readable. ~~~ 另一種注釋是文檔注釋。文檔注釋使用`///`而不是`//`,并且內建Markdown標記支持: ~~~ /// Adds one to the number given. /// /// # Examples /// /// ``` /// let five = 5; /// /// assert_eq!(6, add_one(5)); /// # fn add_one(x: i32) -> i32 { /// # x + 1 /// # } /// ``` fn add_one(x: i32) -> i32 { x + 1 } ~~~ 有另外一種風格的文檔注釋,`//!`,用來注釋包含它的項(也就是說,crate,模塊或者函數),而不是位于它之后的項。它經常用在crate根文件(lib.rs)或者模塊根文件(mod.rs): ~~~ //! # The Rust Standard Library //! //! The Rust Standard Library provides the essential runtime //! functionality for building portable Rust software. ~~~ 當書寫文檔注釋時,加上參數和返回值部分并提供一些用例將是非常,非常有幫助的。你會注意到我們在這里用了一個新的宏:`assert_eq!`。它比較兩個值,并當它們不相等時`panic!`。這在文檔中是非常有幫助的。還有一個宏,`assert!`,它在傳遞給它的值是`false`的時候`panic!`。 你可以使用[rustdoc](#)工具來將文檔注釋生成為HTML文檔,也可以將代碼示例作為測試運行!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看