-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add clarity to the examples of some Vec
& VecDeque
methods
#134310
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Noratrieb (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
In some `Vec` and `VecDeque` examples where elements are i32, examples can seem a bit confusing at first glance if a parameter of the method is an usize.
@rustbot label +A-docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I agree that this makes it a lot clearer!
@bors r+ rollup |
Rollup of 7 pull requests Successful merges: - rust-lang#130361 (std::net: Solaris supports `SOCK_CLOEXEC` as well since 11.4.) - rust-lang#133406 (Add value accessor methods to `Mutex` and `RwLock`) - rust-lang#133633 (don't show the full linker args unless `--verbose` is passed) - rust-lang#134285 (Add some convenience helper methods on `hir::Safety`) - rust-lang#134310 (Add clarity to the examples of some `Vec` & `VecDeque` methods) - rust-lang#134313 (Don't make a def id for `impl_trait_in_bindings`) - rust-lang#134315 (A couple of polonius fact generation cleanups) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134310 - tkr-sh:master, r=Noratrieb Add clarity to the examples of some `Vec` & `VecDeque` methods In some `Vec` and `VecDeque` examples where elements are `i32`, examples can seem a bit confusing at first glance if a parameter of the method is an `usize`. In this case, I think it's better to use `char` rather than `i32`. > [!NOTE] > It's already done in the implementation of `VecDeque::insert` #### Difference - `i32` ```rs let mut v = vec![1, 2, 3]; assert_eq!(v.remove(1), 2); assert_eq!(v, [1, 3]); ``` - `char` ```rs let mut v = vec!['a', 'b', 'c']; assert_eq!(v.remove(1), 'b'); assert_eq!(v, ['a', 'c']); ``` Even tho it's pretty minor, it's a nice to have.
In some
Vec
andVecDeque
examples where elements arei32
, examples can seem a bit confusing at first glance if a parameter of the method is anusize
.In this case, I think it's better to use
char
rather thani32
.Note
It's already done in the implementation of
VecDeque::insert
Difference
i32
char
Even tho it's pretty minor, it's a nice to have.