Conversation
- application-database: 数据库 URL 解析使用 expect() 提供清晰错误消息 - application-database: TOTP 生成代码返回 Result,使用 ? 传播错误 - application-api: 配置访问使用 expect() 替代 unwrap() - application-api: Depot 获取 AccessToken 使用 map_err() 返回授权错误 - application-api: 请求验证使用 ok_or() 和 parse().map_err() 替代 unwrap() - application-api: DetailResponse 从 From 改为 TryFrom 适配 Result 返回值
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
unwrap()调用,改用安全的错误处理方式?操作符和map_err()传播错误Changes
application-database
lib.rs: 数据库 URL 解析使用expect()提提供清晰错误消息tool/totp.rs: TOTP 生成代码返回Result<String>,使用?传播错误application-api
lib.rs: 配置访问使用expect()替代unwrap()v1/totp.rs,v1/users.rs: Depot 获取 AccessToken 使用map_err()返回授权错误request/totp.rs,request/access_token.rs: 请求验证使用ok_or()和parse().map_err()替代unwrap()request/totp.rs:DetailResponse从From改为TryFrom适配Result返回值service/totp.rs: 适配TryFrom调用Verification
cargo check --all-features- 编译通过cargo clippy -- -D warnings- 无警告cargo test --all-features- 4 个测试全部通过