# rust常见的规范

# 01)定义变量一定要使用

rust中定义变量后一定要去使用。不然会warning警告。这个有点像前端的语言Type Script一样。

warning: unused variable: `path`
 --> src/main.rs:5:9
  |
5 |     let path = Path::new(str);
  |         ^^^^ help: if this is intentional, prefix it with an underscore: `_path`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `demo03` (bin "demo03") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running `target\debug\demo03.exe`

1
2
3
4
5
6
7
8
9
10
11
12
Last Updated: 4/13/2025, 8:41:06 AM