- Cheats.rs
- Easy to read and find cheat sheet for Rust
These are some tools to help with the licenses of the libraries the project:
- cargo-license
- List licenses of the libraries
- cargo-lichking
- Check the compatibility of your project license and the libraries licenses
- cargo-about
- Cargo plugin for generating a listing of all of the crates used by a root crate, and the terms under which they are licensed.
Explanation about the built-in traits, nice reminder to review from time to time.
Some of the information is outdated, read with care!
https://llogiq.github.io/2015/07/30/traits.html
-
This will bring all the required extensions for most use cases.
- For large projects, set
-j4
(or less) forcargo check
. This will avoid freezing your system.
- For large projects, set
-
Optimized dark theme
-
Toml snippets
There are cases where the extensions don't work well with the tests, testing with features and workspaces are some of the cases.
For this kind of situation a configuration can be added to launch.json
.
Replace the <libname>
or remove the filter section for simple cases.
Features may be added to the args
section.
For debugging only some specific tests, add the match-filter to the last args
section.
{
"type": "lldb",
"request": "launch",
"name": "Debug specific test",
"cargo": {
"args": [
"test",
"--no-run",
],
"filter": {
"name": "<libname>",
"kind": "lib"
}
},
"args": ["<test filter>"],
"cwd": "${workspaceFolder}"
},
Reference: vadimcn/codelldb#35
Here are some starting structures I like to use in a new project.
I like to have a local Result
type, it's less to write and easier to refactor.
The ideal is to have also your own local Error
type but I usually start with a boxed error and refactor later.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
Good to set when making network or database queries:
pub const APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
These are some derive types that I need more often then not:
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Strong typed generic id: typed_id.rs
- Type safe
- Implements
Deref
and other common traits of the underling type - Same size as the undeling type
struct User;
type UserId = TypedId<u32, User>;