Use when writing Rust code, implementing Rust features, or needing Rust best practices and idioms.
From psnnpx claudepluginhub aladac/claude-pluginsThis skill uses the workspace's default tool permissions.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Configures VPN and dedicated connections like Direct Connect, ExpressRoute, Interconnect for secure on-premises to AWS, Azure, GCP, OCI hybrid networking.
| Tool | Purpose |
|---|---|
Read | Read .rs files |
Write | Create new Rust files |
Edit | Modify Rust code |
Bash | Run cargo, rustc, clippy, rustfmt |
Glob | Find Rust files (*.rs) |
Grep | Search Rust code |
psn:code:rust-cli - Clap CLI developmentpsn:code:rust-test - Rust testingpsn:code:rust-dioxus - Dioxus GUI developmentpsn:code:rust-tooling - Lint/format/typecheckpsn:code:rust-validate - Full validation workflowModern Rust idioms focused on safety, performance, and clarity.
Make invalid states unrepresentable via newtype wrappers:
pub struct Email(String);
impl Email {
pub fn parse(s: &str) -> Result<Self, EmailError> {
if s.contains('@') && s.contains('.') {
Ok(Self(s.to_owned()))
} else {
Err(EmailError::InvalidFormat)
}
}
pub fn as_str(&self) -> &str {
&self.0
}
}
// Can't construct invalid Email
fn send_email(to: Email, subject: Subject) { ... }
thiserroruse thiserror::Error;
#[derive(Debug, Error)]
pub enum ParseError {
#[error("invalid format: {0}")]
InvalidFormat(String),
#[error("missing field: {field}")]
MissingField { field: &'static str },
#[error(transparent)]
Io(#[from] std::io::Error),
}
anyhowuse anyhow::{Context, Result};
fn load_config(path: &Path) -> Result<Config> {
let contents = fs::read_to_string(path)
.context("failed to read config file")?;
let config: Config = toml::from_str(&contents)
.context("failed to parse config")?;
Ok(config)
}
#[derive(Default)]
pub struct RequestBuilder {
url: Option<String>,
method: Method,
headers: HashMap<String, String>,
}
impl RequestBuilder {
pub fn new() -> Self { Self::default() }
pub fn url(mut self, url: impl Into<String>) -> Self {
self.url = Some(url.into());
self
}
pub fn build(self) -> Result<Request, BuildError> {
let url = self.url.ok_or(BuildError::MissingUrl)?;
Ok(Request { url, method: self.method, headers: self.headers })
}
}
// Functional (prefer)
let results: Vec<_> = items
.iter()
.filter(|item| item.is_valid())
.map(|item| item.process())
.collect();
// Early exit with Iterator
let results: Result<Vec<_>, _> = items
.iter()
.map(|item| process(item))
.collect(); // Stops on first Err
// Box: single ownership, heap allocation
let data: Box<LargeStruct> = Box::new(large_struct);
// Arc: shared ownership, multi-thread
let shared: Arc<Config> = Arc::new(config);
// Mutex: interior mutability, multi-thread
let mutex: Mutex<Vec<i32>> = Mutex::new(vec![]);
// lib.rs
pub mod config; // Public module
mod internal; // Private module
pub use config::Config; // Re-export
// src/prelude.rs
pub use crate::config::Config;
pub use crate::error::{Error, Result};
// docker/mod.rs
mod client; // private
pub use client::DockerClient; // docker::DockerClient
Avoid in library code. Use instead:
.unwrap_or(default).unwrap_or_default().expect("reason this can't fail").ok_or(Error::Missing)?Acceptable:
Regex::new(r"^\d+$").unwrap()Never commit:
dbg!() - debug macrotodo!() - unfinished codepanic!() for recoverable errors.unwrap() on user input or external datause foo::* (except use super::* in tests)