<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ### hello world hellow world 示例程序 `main.rs`: ``` fn main() { println!("hello world"); } ``` #### hello world細節 - Rust縮進風格是使用4個空格,不是制表符(`tab`)。 - `println!`調用了一個 Rust 宏(macro)。如果是調用函數,則應輸入`println`(沒有`!`)。當看到符號`!`的時候,就意味著調用的是宏而不是普通函數。 - `"Hello, world!"`是一個字符串。我們把這個字符串作為一個參數傳遞給`println!`,字符串將被打印到屏幕上。 - 該行以分號結尾(`;`),這代表一個表達式的結束和下一個表達式的開始。大部分 Rust 代碼行以分號結尾。 #### 編譯 執行命令: ``` $ rustc main.rs //運行生成的二進制文件 `main` $ ./main //屏幕上打印 hello world ``` ***** ### hello_cargo #### 示例 創建一個hello_cargo ``` $ cargo new hello_cargo cd hello_cargo //可以看到配置文件Cargo.toml跟源碼目錄src //src目錄下有一個main.rs,里面是hello_world程序 ``` 編譯&&執行 ``` //debug $ cargo build //release 編譯 $ cargo build relealse //執行 $ cargo run ``` Cargo 還提供了一個叫`cargo check`的命令。該命令快速檢查代碼確保其可以編譯,但并不產生可執行文件: ``` $ cargo check Checking hello\_cargo v0.1.0 (/home/rust/hello\_cargo) Finished dev \[unoptimized + debuginfo\] target(s) in 0.26s ``` #### 問題 運行在docker首個問題 [Cannot create new Rust project with Docker: “could not determine the current user”](https://stackoverflow.com/questions/51137904/cannot-create-new-rust-project-with-docker-could-not-determine-the-current-use) 解決方式 帶上 -m USER=$USER: ``` $ docker run -it --rm -e USER=$USER -v "$PWD":/home/rust rust:init /bin/bash $ docker run -it -e USER=$USER -v /sources/rust/:/home/project/rust --privileged=true --name rust_test rust:v1 /bin/bash ```
                  <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>

                              哎呀哎呀视频在线观看