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

Change all instances of &Option<T> to Option<&T> #263

Merged
merged 2 commits into from
Nov 16, 2021
Merged

Conversation

nightkr
Copy link
Member

@nightkr nightkr commented Nov 16, 2021

Description

Option<&T> carries the same expressive power, is slightly more efficient, and
makes it easier to express some code with fewer clones.

In general code that provides provides these parameters will need to change from
&foo to foo.as_ref(), and from &Some(foo) to Some(&foo). Rustc has a
specific lint for as_ref.

Review Checklist

  • Code contains useful comments
  • (Integration-)Test cases added (or not applicable)
  • Documentation added (or not applicable)
  • Changelog updated (or not applicable)

Sorry, something went wrong.

`Option<&T>` carries the same expressive power, is slightly more efficient, and
makes it easier to express some code with fewer clones.

In general code that provides provides these parameters will need to change from
`&foo` to `foo.as_ref()`, and from `&Some(foo)` to `Some(&foo)`. Rustc has a
specific lint for `as_ref`.
Copy link
Member

@maltesander maltesander left a comment

Choose a reason for hiding this comment

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

LGTM.

@nightkr nightkr merged commit d9e5fd7 into main Nov 16, 2021
@nightkr nightkr deleted the chore/option-ref branch November 16, 2021 18:08
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

2 participants