Agent skill
rust-2024-migration
Guides users through migrating to Rust 2024 edition features including let chains, async closures, and improved match ergonomics. Activates when users work with Rust 2024 features or nested control flow.
Install this agent skill to your Project
npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/emillindfors/rust-2024-migration
SKILL.md
Rust 2024 Migration Skill
You are an expert at modern Rust patterns from the 2024 edition. When you detect code that could use Rust 2024 features, proactively suggest migrations and improvements.
When to Activate
Activate when you notice:
- Nested if-let expressions
- Manual async closures with cloning
- Cargo.toml with edition = "2021" or earlier
- Code patterns that could benefit from Rust 2024 features
Rust 2024 Feature Patterns
1. Let Chains (Stabilized in 1.88.0)
What to Look For: Nested if-let or match expressions
Before (Nested):
// ❌ Deeply nested, hard to read
fn process_user(id: &str) -> Option<String> {
if let Some(user) = db.find_user(id) {
if let Some(profile) = user.profile {
if profile.is_active {
if let Some(email) = profile.email {
return Some(email);
}
}
}
}
None
}
After (Let Chains):
// ✅ Flat, readable chain
fn process_user(id: &str) -> Option<String> {
if let Some(user) = db.find_user(id)
&& let Some(profile) = user.profile
&& profile.is_active
&& let Some(email) = profile.email
{
Some(email)
} else {
None
}
}
Suggestion Template:
Your nested if-let can be flattened using let chains (Rust 2024):
if let Some(user) = get_user(id)
&& let Some(profile) = user.profile
&& profile.is_active
{
// All conditions met
}
This requires Rust 1.88+ and edition = "2024" in Cargo.toml.
2. Async Closures (Stabilized in 1.85.0)
Before:
// ❌ Manual async closure with cloning
let futures: Vec<_> = items
.iter()
.map(|item| {
let item = item.clone(); // Need to clone for async move
async move {
fetch_data(item).await
}
})
.collect();
After:
// ✅ Native async closure
let futures: Vec<_> = items
.iter()
.map(async |item| {
fetch_data(item).await
})
.collect();
3. Async Functions in Traits (Native since 1.75)
Before:
// ❌ OLD: Required async-trait crate
use async_trait::async_trait;
#[async_trait]
trait UserRepository {
async fn find_user(&self, id: &str) -> Result<User, Error>;
}
After:
// ✅ NEW: Native async fn in traits (Rust 1.75+)
trait UserRepository {
async fn find_user(&self, id: &str) -> Result<User, Error>;
}
impl UserRepository for PostgresRepo {
async fn find_user(&self, id: &str) -> Result<User, Error> {
self.db.query(id).await // No macro needed!
}
}
When async-trait is Still Needed:
// For dynamic dispatch (dyn Trait)
use async_trait::async_trait;
#[async_trait]
trait Plugin: Send + Sync {
async fn execute(&self) -> Result<(), Error>;
}
// This requires async-trait:
let plugins: Vec<Box<dyn Plugin>> = vec![
Box::new(PluginA),
Box::new(PluginB),
];
4. Match Ergonomics 2024
Rust 2024 Changes:
// Rust 2024: mut doesn't force by-value
match &data {
Some(mut x) => {
// x is &mut T (not T moved)
x.modify(); // Modifies through reference
}
None => {}
}
5. Gen Blocks (Stabilized in 1.85.0)
Before (Manual Iterator):
struct RangeIter {
current: i32,
end: i32,
}
impl Iterator for RangeIter {
type Item = i32;
fn next(&mut self) -> Option<Self::Item> {
if self.current < self.end {
let result = self.current;
self.current += 1;
Some(result)
} else {
None
}
}
}
After (Gen Block):
fn range_iter(start: i32, end: i32) -> impl Iterator<Item = i32> {
gen {
let mut current = start;
while current < end {
yield current;
current += 1;
}
}
}
Migration Checklist
When migrating to Rust 2024:
- Update Cargo.toml:
[package]
edition = "2024"
rust-version = "1.85" # Minimum version for Rust 2024
- Run cargo fix:
cargo fix --edition
- Convert nested if-let to let chains
- Remove async-trait where not needed (keep for dyn Trait)
- Replace manual iterators with gen blocks
- Use const functions where appropriate
Your Approach
When you see code patterns:
- Identify nested control flow → suggest let chains
- See async-trait → check if native async fn works
- Manual iterators → suggest gen blocks
- Async closures with cloning → suggest native syntax
Proactively suggest Rust 2024 patterns for more elegant, idiomatic code.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
perigon-backend
Perigon ASP.NET Core + EF Core + Aspire conventions
perigon-agent
Pointers for Copilot/agents to apply Perigon conventions
perigon-angular
Angular 21+ standalone/Material/signal conventions for Perigon WebApp
fastapi-mastery
Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.
context7-efficient
Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.
browser-use
Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.
Didn't find tool you were looking for?