Skip to content

Rust Coding Standards

Manage and enforce Rust coding standards across your team with CodeContext. Ensure AI assistants follow your Rust conventions through MCP integration.

Standard Categories

Naming Conventions
Error Handling
Lifetime Patterns
Trait Design
Module Structure
Unsafe Usage
Testing Patterns
Documentation Comments

Example Standard

Rust
// Standard: Use thiserror for custom error types
// Category: Error Handling

// Avoid
#[derive(Debug)]
enum AppError {
    NotFound(String),
    Database(String),
}

impl std::fmt::Display for AppError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::NotFound(msg) => write!(f, "not found: {}", msg),
            Self::Database(msg) => write!(f, "database error: {}", msg),
        }
    }
}

// Prefer
use thiserror::Error;

#[derive(Debug, Error)]
enum AppError {
    #[error("not found: {0}")]
    NotFound(String),
    #[error("database error: {source}")]
    Database { #[from] source: sqlx::Error },
}

Frequently Asked Questions

Can CodeContext help with Rust-specific patterns?

Yes. Document your team's conventions for error handling, lifetime management, trait design, unsafe code policies, and any crate-specific patterns you follow.

Does this replace clippy?

No. Clippy handles automated lint checks. CodeContext manages higher-level standards like architecture decisions, crate selection policies, and design patterns that cannot be expressed as lint rules.

Can AI assistants understand Rust ownership patterns from my standards?

Yes. When you document your ownership and borrowing conventions in CodeContext, AI assistants can reference them through MCP to generate code that follows your team's patterns.

Manage Rust Standards with CodeContext

Define your Rust conventions and deliver them to AI assistants automatically.