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

Most char API should use Copy instead of Ref #241

Open
behnam opened this issue Nov 5, 2018 · 0 comments
Open

Most char API should use Copy instead of Ref #241

behnam opened this issue Nov 5, 2018 · 0 comments
Labels
A: lib-api Library API enhancement Enhancements to existing features L: easy Level: Easy

Comments

@behnam
Copy link
Member

behnam commented Nov 5, 2018

Most functions taking char as input, specially those taking self with a small struct only having one or two char, should be migrated to take self instead of &self.

Some of the clippy warnings:

warning: this argument is passed by reference, but would be more efficient if passed by value
   --> unic/char/range/src/range.rs:180:21
    |
180 |     pub fn contains(&self, ch: char) -> bool {
    |                     ^^^^^ help: consider passing by value instead: `self`
    |
    = note: #[warn(clippy::trivially_copy_pass_by_ref)] on by default
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

warning: this argument is passed by reference, but would be more efficient if passed by value
   --> unic/char/range/src/range.rs:190:21
    |
190 |     pub fn cmp_char(&self, ch: char) -> Ordering {
    |                     ^^^^^ help: consider passing by value instead: `self`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

warning: this argument is passed by reference, but would be more efficient if passed by value
   --> unic/char/range/src/range.rs:203:16
    |
203 |     pub fn len(&self) -> usize {
    |                ^^^^^ help: consider passing by value instead: `self`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

warning: this argument is passed by reference, but would be more efficient if passed by value
   --> unic/char/range/src/range.rs:208:21
    |
208 |     pub fn is_empty(&self) -> bool {
    |                     ^^^^^ help: consider passing by value instead: `self`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

warning: this argument is passed by reference, but would be more efficient if passed by value
   --> unic/char/range/src/range.rs:213:17
    |
213 |     pub fn iter(&self) -> CharIter {
    |                 ^^^^^ help: consider passing by value instead: `self`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref
@behnam behnam added A: lib-api Library API L: easy Level: Easy labels Nov 5, 2018
@behnam behnam added the enhancement Enhancements to existing features label Apr 8, 2019
bors bot added a commit that referenced this issue Jul 24, 2019
237: travis: Enable Windows and MacOS builds r=behnam a=behnam



<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/open-i18n/rust-unic/237)
<!-- Reviewable:end -->


252: Clippy fixes and changing refs to Copy r=CAD97 a=JamesHinshelwood

Updated clippy allows from `cfg_attr` to proc-macro style.
Fixed #241 + more - Changed a few `impl`s to take `self` instead of `&self`, when they are `Copy` types.

`cargo clippy` should run without any warnings now.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/open-i18n/rust-unic/252)
<!-- Reviewable:end -->


Co-authored-by: Behnam Esfahbod <[email protected]>
Co-authored-by: JamesHinshelwood <[email protected]>
bors bot added a commit that referenced this issue Jul 24, 2019
252: Clippy fixes and changing refs to Copy r=CAD97 a=JamesHinshelwood

Updated clippy allows from `cfg_attr` to proc-macro style.
Fixed #241 + more - Changed a few `impl`s to take `self` instead of `&self`, when they are `Copy` types.

`cargo clippy` should run without any warnings now.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/open-i18n/rust-unic/252)
<!-- Reviewable:end -->


Co-authored-by: JamesHinshelwood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: lib-api Library API enhancement Enhancements to existing features L: easy Level: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant