Skip to content

Commit

Permalink
Merge pull request #2 from okbug/study/rust
Browse files Browse the repository at this point in the history
学习Rust的笔记
  • Loading branch information
okbug authored Nov 17, 2021
2 parents 83286a4 + e8f0403 commit a61bb30
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions learn-rust/note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
创建项目:

`cargo new project-name`

运行项目:

`cargo run`

或者`cargo build`
build之后要在target文件夹下面运行可执行文件

## mod的概念
mod类似nodejs中的一个个本地模块
```rust
// main.rs

mod mod1
fn main() {
println!("{}", mod1::TEXT);
}

// mod1.rs 或者mod1文件下下面的mod.rs文件
pub const TEXT: &str = "Hello, World";
```

使用这个办法可以在main中引入我们的mod1中的变量和方法

0 comments on commit a61bb30

Please sign in to comment.