-
-
Notifications
You must be signed in to change notification settings - Fork 750
Make sure that that every function in Phobos has an example: std.{algorithm,array,ascii,base64} #5581
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
Merged
Merged
Make sure that that every function in Phobos has an example: std.{algorithm,array,ascii,base64} #5581
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
334642b
has_public_example: std.algorithm.comparison
wilzbach 8180178
has_public_example: std.algorithm.mutation
wilzbach b6512b9
has_public_example: std.array
wilzbach cc80b57
has_public_example: std.ascii
wilzbach 54c47a7
has_public_example: std.base64
wilzbach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1659,6 +1659,36 @@ enum SwapStrategy | |
| stable, | ||
| } | ||
|
|
||
| /// | ||
| @safe unittest | ||
| { | ||
| import std.stdio; | ||
| import std.algorithm.sorting : partition; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you import "partition"?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No particular reason except for copy/pasting from the test below :/ |
||
| int[] a = [0, 1, 2, 3]; | ||
| assert(remove!(SwapStrategy.stable)(a, 1) == [0, 2, 3]); | ||
| a = [0, 1, 2, 3]; | ||
| assert(remove!(SwapStrategy.unstable)(a, 1) == [0, 3, 2]); | ||
| } | ||
|
|
||
| /// | ||
| @safe unittest | ||
| { | ||
| import std.algorithm.sorting : partition; | ||
|
|
||
| // Put stuff greater than 3 on the left | ||
| auto arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
| assert(partition!(a => a > 3, SwapStrategy.stable)(arr) == [1, 2, 3]); | ||
| assert(arr == [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]); | ||
|
|
||
| arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
| assert(partition!(a => a > 3, SwapStrategy.semistable)(arr) == [2, 3, 1]); | ||
| assert(arr == [4, 5, 6, 7, 8, 9, 10, 2, 3, 1]); | ||
|
|
||
| arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
| assert(partition!(a => a > 3, SwapStrategy.unstable)(arr) == [3, 2, 1]); | ||
| assert(arr == [10, 9, 8, 4, 5, 6, 7, 3, 2, 1]); | ||
| } | ||
|
|
||
| /** | ||
| Eliminates elements at given offsets from `range` and returns the shortened | ||
| range. | ||
|
|
||
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I wish we could generate this list
manuallyautomatically.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.
FYI the list was generated automatically: #5501 - just reducing it isn't automated :/
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.
Whoops, I just realized I wrote manually by mistake. At least the generating part works so we're not too bad off.