Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a Clippy warning (Clippy 0.0.212 / Rust 1.38.0) #242

Merged
merged 1 commit into from
Oct 13, 2019

Conversation

tatsuya6502
Copy link
Contributor

@tatsuya6502 tatsuya6502 commented Oct 6, 2019

Clippy in the latest Rust stable emits the following warning:

error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
  --> rustler/src/resource.rs:90:18
   |
88 |     if res.is_some() {
   |        ------------- the check is happening here
89 |         Some(ResourceType {
90 |             res: res.unwrap(),
   |                  ^^^^^^^^^^^^
   |
   = note: `-D clippy::unnecessary-unwrap` implied by `-D warnings`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap

This pull request addresses the warning by changing the codes as suggested by Clippy.

Version Info

Rust 1.38.0 stable

$ rustc -V
rustc 1.38.0 (625451e37 2019-09-23)

$ cargo clippy -V
clippy 0.0.212 (3aea860 2019-09-03)

* Fix the following warning from Clippy 0.0.212 (Rust 1.38.0):
  https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
@filmor
Copy link
Member

filmor commented Oct 6, 2019

There's an equivalent change already included in my pending PR #239 :)

Copy link
Member

@scrogson scrogson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@filmor I'm merging this because CI is now failing because of this. Please rebase your changes on master.

@scrogson scrogson merged commit 162cfe2 into rusterlium:master Oct 13, 2019
@tatsuya6502 tatsuya6502 deleted the fix-clippy-1.38.0 branch October 15, 2019 09:36
@scrogson scrogson mentioned this pull request Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants