Error Handling: Library vs Application Library Error Design Principles Define specific error types - Don't use anyhow in libraries Implement std::error::Error - For compatibility Provide error variant
阅读全文
Error Handling Patterns
Error Handling Patterns The ? Operator Basic Usage fn read_config() -> Result<Config, io::Error> { let content = std::fs::read_to_string("config.toml")?; let config: Config = toml::from_str(&
阅读全文
Error Handling
name: m06-error-handling description: "CRITICAL: Use for error handling. Triggers: Result, Option, Error, ?, unwrap, expect, panic, anyhow, thiserror, when to panic vs return Result, custom error, err
阅读全文
Thinking in Rust: Mental Models
Thinking in Rust: Mental Models Core Mental Models 1. Ownership as Resource Management Traditional: "Who has a pointer to this data?" Rust: "Who OWNS this data and is responsible for freeing it?" Key
阅读全文
Mental Models
name: m14-mental-model description: "Use when learning Rust concepts. Keywords: mental model, how to think about ownership, understanding borrow checker, visualizing memory layout, analogy, misconcept
阅读全文
Domain Error Strategy
name: m13-domain-error description: "Use when designing domain error handling. Keywords: domain error, error categorization, recovery strategy, retry, fallback, domain error hierarchy, user-facing vs
阅读全文
Resource Management
name: m02-resource description: "CRITICAL: Use for smart pointers and resource management. Triggers: Box, Rc, Arc, Weak, RefCell, Cell, smart pointer, heap allocation, reference counting, RAII, Drop,
阅读全文
Resource Lifecycle
name: m12-lifecycle description: "Use when designing resource lifecycles. Keywords: RAII, Drop, resource lifecycle, connection pool, lazy initialization, connection pool design, resource cleanup patte
阅读全文
Rust Refactor Helper
name: rust-refactor-helper description: "Safe Rust refactoring with LSP analysis. Triggers on: /refactor, rename symbol, move function, extract, 重构, 重命名, 提取函数, 安全重构" argument-hint:
阅读全文
Rust Code Navigator
name: rust-code-navigator description: "Navigate Rust code using LSP. Triggers on: /navigate, go to definition, find references, where is defined, 跳转定义, 查找引用, 定义在哪, 谁用了这个"
阅读全文