learn rust demo 学习资源: https://github.com/tyrchen/geektime-rust/tree/master https://mp.weixin.qq.com/s/I1-7U0ACosnxvtaplKYXIQ
从零开始 用 Rust 语言写一个基于 RISC-V 架构的类 Unix 内核 https://rcore-os.cn/rCore-Tutorial-Book-v3/
rustup show
rustup update
rustup self uninstall
rustup default stable-x86_64-pc-windows-gnu
rustup -h
rustup toolchain list
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup toolchain uninstall stable-x86_64-pc-windows-gnu
rustup toolchain link ""
rustup override list
rustup override set --path
rustup override unset --path
rustup target list
rustup target add
rustup target remove
rustup target add --toolchain
rustup component list
rustup component add
rustup component remove
rustc 相关
rustc --version cargo 相关
cargo --version
cargo new <project_name>
cargo build
cargo run
cargo check
cargo install
cargo uninstall
cargo -h 0x3. 配置工具链安装位置 在系统环境变量中添加如下变量:
CARGO_HOME 指定 cargo 的安装目录
RUSTUP_HOME 指定 rustup 的安装目录
默认分别安装到用户目录下的.cargo 和.rustup 目录
0x4. 配置国内镜像 1). 配置 rustup 国内镜像 在系统环境变量中添加如下变量:
RUSTUP_DIST_SERVER:https://mirrors.ustc.edu.cn/rust-static RUSTUP_UPDATE_ROOT:https://mirrors.ustc.edu.cn/rust-static/rustup 2). 配置 cargo 国内镜像 在 cargo 安装目录下新建 config 文件(注意 config 没有任何后缀),文件内容如下:
[source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'tuna'
[source.tuna] registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"
0x5. Windows 交叉编译 Linux 程序 目标服务器是 Linux(CentOS 7) 64bit, 所以我们添加的 target 应该是x86_64-unknown-linux-gnu(动态依赖) 或者x86_64-unknown-linux-musl(静态依赖)
解释:
动态依赖:目标服务器需要包含动态依赖的相关库(用户共享库)
静态依赖,目标服务器不需要包含相应的库,但是打包文件会更大些
1). 添加需要的 target
rustup target add x86_64-unknown-linux-musl
2). 在 cargo 安装目录下新建 config 文件(注意 config 没有任何后缀),添加的文件内容如下:
[target.x86_64-unknown-linux-musl] linker = "rust-lld" 3). 构建
cargo build --target x86_64-unknown-linux-musl #rust学习日记 https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&__biz=MzkwMjI5MjA5MA==&scene=1&album_id=2075607640214126593&count=3#wechat_redirect #rust入门 https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&__biz=MzU0MTg5MDMzOA==&scene=1&album_id=3187499705652690949&count=3#wechat_redirect #rusut进阶 https://mp.weixin.qq.com/mp/appmsgalbum?__biz=Mzg5MDg4NTAzMg==&action=getalbum&album_id=3122274487372251145&scene=173&subscene=&sessionid=svr_d1b7bf56402&enterid=1703171241&from_msgid=2247484175&from_itemidx=1&count=3&nolastread=1#wechat_redirect #rust中级 https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&__biz=MzkwMjI5MjA5MA==&scene=1&album_id=2529793839025405952&count=3#wechat_redirect #LeetCode in Rust https://github.com/aylei/leetcode-rust #Rust 数据结构和算法 https://github.com/QMHTMY/RustBook/tree/main/books #The Algorithms (Rust算法) https://github.com/TheAlgorithms/Rust #小争哥讲算法(包括 Rust) https://github.com/wangzheng0822/algo 官方的 rust book https://doc.rust-lang.org/book/title-page.html 官方 rust 死灵书 https://doc.rust-lang.org/nomicon/intro.html 通过例子学 Rust https://rustwiki.org/zh-CN/rust-by-example/index.html 官方 rustlings 小练习 https://rustlings.cool/ Rust 语言圣经 https://course.rs/basic/intro.html Google 出的 Rust 教程 https://google.github.io/comprehensive-rust/welcome.html Rust 程序设计语言 https://kaisery.github.io/trpl-zh-cn/title-page.html Rust 原子操作和锁 https://marabos.nl/atomics/ Rust 原子和锁—中文翻译 https://atomics.rs/about-book.html Awesome-rust rust 相关资料、第三方库列表 https://github.com/rust-unofficial/awesome-rust Learn Rust Easy 一本中文入门书 https://rustycab.github.io/LearnRustEasy/ 书籍、博客、视频 《Rust 编程之道》 《Rust 权威指南》 《Rust 程序设计·第二版》 《深入理解 Rust 并发编程》 《Rust 实战》 《The Rust Programming Language》 《Rust For Rustaceans》 《Programming Rust—Fast, Safe Systems Development》 《Command-Line Rust》 《Rust Crash Course》 《Systems Programming Rust》 《Rust Atomics and Locks》 The Week in Rust https://this-week-in-rust.org/ Rust 语言中文社区 https://rustcc.cn/ https://rust-exercises.com/