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

Inline immediate .unwrap after Some(_) #9816

Closed
KisaragiEffective opened this issue Nov 8, 2022 · 2 comments
Closed

Inline immediate .unwrap after Some(_) #9816

KisaragiEffective opened this issue Nov 8, 2022 · 2 comments
Labels
A-lint Area: New lints

Comments

@KisaragiEffective
Copy link
Contributor

What it does

Suggesting inline Some(_) and .unwrap() in continuous line.

Before

let expr = "";
let token = Some(expr);
let token = token.unwrap();
// assert_eq!(expr, token)

After

let expr = "";
let token = expr;

Lint Name

unnecessary_option

Category

complexity

Advantage

  • Remove complexibility

Drawbacks

None

Example

// let expr = "for any value and type";
let token = Some(expr);
let token = token.unwrap();
// assert_eq!(expr, token)

Could be written as:

let token = expr;
@KisaragiEffective KisaragiEffective added the A-lint Area: New lints label Nov 8, 2022
@KisaragiEffective KisaragiEffective changed the title Inline .unwrap after Some(_) Inline immediate .unwrap after Some(_) Nov 8, 2022
@y21
Copy link
Member

y21 commented Jul 21, 2023

@KisaragiEffective
Copy link
Contributor Author

Yes, this should be closed because #10358 is merged and landed in today’s (>= 1.69.0) toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants