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

Report usages of &Vec<T> in function arguments #7640

Closed
jdm opened this issue Sep 15, 2015 · 7 comments
Closed

Report usages of &Vec<T> in function arguments #7640

jdm opened this issue Sep 15, 2015 · 7 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Sep 15, 2015

There's no reason for a function to accept a &Vec<T> argument instead of &[T], since they allow the same operations and the first is an extra pointer dereference. We should check for the string : &Vec< in Rust source files and report any instances found.

Code: python/tidy.py

@jdramani
Copy link
Contributor

@jdramani jdramani commented Sep 15, 2015

I think I can do it.

@jdm
Copy link
Member Author

@jdm jdm commented Sep 15, 2015

Great!

@wilfreddenton
Copy link

@wilfreddenton wilfreddenton commented Sep 20, 2015

I'm new to Rust so I just need some clarification. I thought that vectors allow for adding and removing elements whereas arrays do not. A function needing to manipulate a collection parameter's items would need the parameter to be a vector, no?

@jdm
Copy link
Member Author

@jdm jdm commented Sep 20, 2015

Those would need to be mutable, ie. &mut Vec. Immutable references provide no additional functionality over slices.

@wilfreddenton
Copy link

@wilfreddenton wilfreddenton commented Sep 20, 2015

Oh right. thanks for the help!

@sinistersnare
Copy link

@sinistersnare sinistersnare commented Sep 25, 2015

It seems clippy has this lint

jdramani added a commit to jdramani/servo that referenced this issue Sep 27, 2015
bors-servo pushed a commit that referenced this issue Sep 27, 2015
Check for Extra pointer dereferencing

Solves issue #7640

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7643)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Sep 27, 2015
Check for Extra pointer dereferencing

Solves issue #7640

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7643)
<!-- Reviewable:end -->
josiahdaniels added a commit to josiahdaniels/servo that referenced this issue Sep 28, 2015
@Manishearth
Copy link
Member

@Manishearth Manishearth commented Oct 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.