571
社区成员
发帖
与我相关
我的任务
分享受老师的影响,又写了一个Rust的环境配置,GO语言的那篇在这里
https://bbs.csdn.net/topics/605512104
笔记本:M1 MacBook Arm64
系统:MacOS12.3
编辑调试:VSCode
运行下面的命令
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

选择1 默认即可。
推荐安装rust-analyzer

使用cargo init 创建一个空项目。项目结构如下:

可见默认已经设置好git。
第一版代码:
use std::io;
fn main() {
let mut s=String::new();
println!("请输入命令:");
io::stdin().read_line(&mut s).expect("read error");
let mut it=s.split_whitespace();
match it.next().unwrap() {
"help"| "h" => println!("帮助信息"),
"test" | "t" => println!("测试信息"),
_ => println!("输入无效"),
}
}
点击main上面的按钮即可运行和断点调试。


也可使用cargo run等命令运行程序。
git add . git commit -m "first commit"
首先在github上新建一个项目
将项目上传
git remote add origin https://github.com/xxxxxx.git git branch -M main git push -u origin main
https://github.com/AnitaMax/Rust_Menu_Tool
作者:585