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

option: rm functions that duplicate methods #5414

Closed
wants to merge 1 commit into from
Closed

option: rm functions that duplicate methods #5414

wants to merge 1 commit into from

Conversation

thestinger
Copy link
Contributor

No description provided.

@brson
Copy link
Contributor

brson commented Mar 16, 2013

I'm in favor of doing this for all of core and std but I think it requires some discussion. Last time this was brought up @catamorphism had some concerns. We do have plans to make methods also usable as functions, which would give us the best of both worlds.

@catamorphism
Copy link
Contributor

@thestinger , can you rebase? Since the eventual plan is to have a way to treat methods as functions, I'm ok with merging this.

Thanks!

@bors bors closed this Mar 27, 2013
oli-obk pushed a commit to oli-obk/rust that referenced this pull request May 2, 2020
Add new lint for `Result<T, E>.map_or(None, Some(T))`

Fixes rust-lang#5414

PR Checklist
---
- [x] Followed lint naming conventions (the name is a bit awkward, but it seems to conform)
- [x] Added passing UI tests (including committed .stderr file)
- [x] cargo test passes locally
- [x] Executed cargo dev update_lints
- [x] Added lint documentation
- [x] Run cargo dev fmt

`Result<T, E>` has an [`ok()`](https://doc.rust-lang.org/std/result/enum.Result.html#method.ok) method that adapts a `Result<T,E>` into an `Option<T>`.
It's possible to get around this adapter by writing `Result<T,E>.map_or(None, Some)`.

This lint is implemented as a new variant of the existing [`option_map_none` lint](rust-lang/rust-clippy#2128)
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.

4 participants