Make great things

What I cannot create, I do not understand.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2021年1月28日

摘要: 原文链接 https://edgarluque.com/blog/wrapping-errors-in-rust 当我在开发 paypal-rs 库时, 注意到了错误处理不是很好. 在这个库中, 我需要处理 2 中不同类型的错误: HTTP 相关错误, reqwest::Error Paypal A 阅读全文
posted @ 2021-01-28 23:11 wbin91 阅读(387) 评论(0) 推荐(0) 编辑

摘要: 最近在刷 Leetcode, 每日题打卡题经常出现并查集, 这里记录下使用 Rust 实现的并查集. pub struct UnionFind { n: usize, fa: Vec<usize>, } impl UnionFind { pub fn new(n: usize) -> Self { 阅读全文
posted @ 2021-01-28 22:00 wbin91 阅读(193) 评论(0) 推荐(0) 编辑

摘要: 原文地址 https://leshow.github.io/post/cheat_rank_n/ 假设你有一个 enum 类描述一组可能的分支, 有一些函数需要对可能的分支进行处理, 而对每个分支存在一个对应的类型, 比如 enum Var { One, Two, } #[derive(Serial 阅读全文
posted @ 2021-01-28 13:51 wbin91 阅读(280) 评论(0) 推荐(0) 编辑