Crates.io | leetcode-in-rust |
lib.rs | leetcode-in-rust |
version | 0.2.10 |
source | src |
created_at | 2023-03-07 04:48:07.069605 |
updated_at | 2023-03-07 04:48:07.069605 |
description | Personal solutions to LeetCode problems using Rust language |
homepage | https://leetcode-rust.dongs.xyz/ |
repository | https://github.com/zhongdongy/leetcode_rust |
max_upload_size | |
id | 803295 |
size | 763,811 |
Rust documentations see https://leetcode-rust.zhongdongy.com or https://leetcode-rust.pages.dev/.
Note: all problems descriptions collected from LeetCode website, 力扣 and all related credits go to LeetCode, 力扣 and its communities. Authors of this repository CANNOT and WILL NOT guarantee the correctness of the problem descriptions and solutions.
Run cargo doc
and find the documentation inside target/doc/leetcode_rust/
directory.
This command will empty the docs/
directory and place newly generated docs
there. The documentations are deployed to Cloudflare Pages. Due to build
environment limitations, the docs must be built before pushing to GitHub (so
Cloudflare directly fetches the contents and build on Pages).
./docsgen.sh
Solution tests are located in tests/problems
directory, and grouped by its
problem numbers. Each problem test group (e.g. p000_0xxx.rs
) corresponds to a
test case module directory (e.g. cases/c000_0xx/
). Each problem test has its
own case definitions, to use the test cases, just import and call use_case()
function.
To run all solution tests, simply run:
cargo test --test solutions # LeetCode problems
cargo test --test solutions_cn # 力扣题库
cargo test --doc
cargo test --lib
cargo test --tests
Suppose you would like to test solution for problem #5, run:
cargo test --test solutions p000_005
关于 Crate 提供的各个解法的 Rust 文档,请参阅 https://leetcode-rust.dongs.xyz/。
请注意,所有的题目来源于 LeetCode 网站和力扣。所有题目的著作权属于上述两个平台及相应的社区。作者不能也不会保证题目描述、解法的正确性。
在项目根目录执行 cargo doc
命令,然后访问 target/doc/leetcode_rust/
目录可以
找到生成的最新文档。
下述命令将会清空您本地项目目录下的 docs/
文件夹,然后将新生成的内容放入其中。由于此文档
部署在 Cloudflare Pages 服务上,而该服务暂不支持使用 Cargo 构建,所以必须在每次推送
最新更改到 GitHub 之前执行本地文档构建。
./docsgen.sh
所有的解法验证程序都位于 tests/problems_cn
目录下,并按照题目编号进行分组。
每个问题组(如 p000_0xx.rs
代表编号 000 到 099 的题目)对应一个单独的测试用例目录
(如 cases/c000_0xx/
)。每个问题的验证程序都提供了国际版、国内版两组测试用例,但其中的
大部分都相同样的。要使用某个问题的测试用例,只需要将其引入,然后调用公有的 use_case()
函数,它的返回值就是测试用例列表。
执行下面的命令来执行所有问题的解法:
cargo test --test solutions # LeetCode 国际版题库
cargo test --test solutions_cn # 力扣题库
cargo test --doc
cargo test --lib
cargo test --tests
假设您想要验证问题 #5 的解,那么可以执行下面的命令:
cargo test --test solutions p000_005