Add an example to show how to insert item to a sorted vec#63442
Merged
bors merged 2 commits intorust-lang:masterfrom Aug 11, 2019
Merged
Add an example to show how to insert item to a sorted vec#63442bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
23f34f5 to
93839c3
Compare
Member
|
@bors r+ rollup=always |
Collaborator
|
📌 Commit 93839c3 has been approved by |
src/libcore/slice/mod.rs
Outdated
| /// let num = 42; | ||
| /// let idx = match s.binary_search(&num) { | ||
| /// Ok(idx) => idx, | ||
| /// Err(idx) => idx, |
Contributor
There was a problem hiding this comment.
The arms could be simplified by using Ok(idx) | Err(idx) => idx
Member
There was a problem hiding this comment.
I personally find current code clearer than that but r=me with this changed as well.
Contributor
There was a problem hiding this comment.
This should be further simplified to let Ok(idx) | Err(idx) = s.binary_search(&num); once we have or-patterns, #54883.
Contributor
Author
There was a problem hiding this comment.
I use unwrap_or_else. Do you prefer it instead?
Member
|
The identity closure always irks me but this works too. @bors r+ |
Collaborator
|
📌 Commit 30ba4bd has been approved by |
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this pull request
Aug 11, 2019
…k-Simulacrum Add an example to show how to insert item to a sorted vec Closes rust-lang#61684 cc rust-lang#61742 r? @Mark-Simulacrum, @jonas-schievink
bors
added a commit
that referenced
this pull request
Aug 11, 2019
Rollup of 8 pull requests Successful merges: - #61969 (Add #[repr(transparent)] for several types) - #62108 (Use sharded maps for queries) - #63149 (resolve: Populate external modules in more automatic and lazy way) - #63346 (Lint on some incorrect uses of mem::zeroed / mem::uninitialized) - #63433 (Miri shouldn't look at types) - #63440 (rename RUST_CTFE_BACKTRACE to RUSTC_CTFE_BACKTRACE) - #63442 (Add an example to show how to insert item to a sorted vec) - #63459 (syntax: account for CVarArgs being in the argument list.) Failed merges: r? @ghost
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this pull request
Aug 11, 2019
…k-Simulacrum Add an example to show how to insert item to a sorted vec Closes rust-lang#61684 cc rust-lang#61742 r? @Mark-Simulacrum, @jonas-schievink
bors
added a commit
that referenced
this pull request
Aug 11, 2019
Rollup of 8 pull requests Successful merges: - #61969 (Add #[repr(transparent)] for several types) - #63346 (Lint on some incorrect uses of mem::zeroed / mem::uninitialized) - #63433 (Miri shouldn't look at types) - #63440 (rename RUST_CTFE_BACKTRACE to RUSTC_CTFE_BACKTRACE) - #63441 (Derive Debug for CrateInfo) - #63442 (Add an example to show how to insert item to a sorted vec) - #63453 (rustdoc: general cleanup) - #63464 (Copy ty::Instance instead of passing by reference) Failed merges: r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61684
cc #61742
r? @Mark-Simulacrum, @jonas-schievink