Skip to content

Day 21 - 错误处理进阶

thiserror

rust
use thiserror::Error;

#[derive(Error, Debug)]
pub enum MyError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),
    
    #[error("Parse error: {0}")]
    Parse(#[from] std::num::ParseIntError),
    
    #[error("Custom: {0}")]
    Custom(String),
}

📅 学习进度

Day主题状态
01-20基础/测试
21错误处理进阶
22Web开发

本文为Rust 30天学习计划第21天内容

📚 导航

| ← Day 20 - 上一章 | Day 22 - 下一章 →

最后更新: