Xianqiao Wang

Xianqiao Wang

Some records of life and study

  • Home

Rust 处理多种错误类型

https://rustwiki.org/zh-CN/rust-by-example/error/multiple_error_types.html

  1. 包含多种错误
  2. 自定义成一种错误
  3. Box // into() 自动转类型
  4. 使用 ? 自动转 Box // ? 要么 unwrap 要么自动 return Err(From::from(err))
  5. 用 enum 包装各种错误

Published by Xianqiao Wang on December 25th, 2019

  • Rust
  • RSS

© 2025 Xianqiao's Site.

Design by Fabien Penso. Powered by Postach.io