-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cleaned up, documented, wrote tests for std::bool
#10007
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
Conversation
I think the value of duplicating the standard operator traits is questionable but I've never been sure enough to go ahead and remove these functions. |
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// Trait impls on `bool` | ||
///////////////////////////////////////////////////////////////////////////// |
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 think that this may show up with a lot of slashes on the documentation of FromStr
for bool, could you check to make sure that this doesn't show up?
Looks good to me! So long as the rustdoc documentation looks OK, r+ |
/// assert_eq!(std::bool::is_true(false), false); | ||
/// ``` | ||
#[inline] | ||
pub fn is_true(v: bool) -> bool { v } |
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.
This function seems extremely removable, as does is_false
and the various operator wrappers.
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.
Especially now that we have a trait & they are methods.
The rustdocs look fine, those kinds of comment decorators get filtered out. :) |
A general note to the 'useless' functions and methods I completely agree that they serve no practical purpose for anyone who has used a C-like language for more than half an hour. But I think their existence can still be justified:
Ideally we could just implement the freestanding functions as methods on If those are weak reasons, I might also just remove them, but I don't see any harm in keeping them. Related, I added the |
Probably better served by examples written expressly for these purposes (e.g. in a trait tutorial).
You mean like
But it's non-zero: e.g. keeping the doc examples up-to-date.
This is a little like people doing if (blah().is_true() == is_true(true)) == is_false(true.is_true()) { ... } being legal.)
They make this file 600 lines with a plethora of weird and wonderful and useless functions & methods, rather than keeping it simple, and the bool API really doesn't need to be huge and complicated like this.
This is correct. I'm not too fussed about keeping the |
Okay then, removed the unnecessary functions and methods. Nothing else used them anyway, and we'll probably get unified function call syntax before someone wants to. |
@Kimundi Can you squash your changes in one commit? |
Removed unused import warning in std::mem and cleaned it up too Removed is_true and is_false from std::bool Removed freestanding functions in std::bool
@adridu59: Done. |
Additionally: - Sorted the prelude reexports - Removed unused import warning in std::mem and cleaned it up too (I was bored 👻 )
Fix ICE in `result_large_err` with uninhabited enums fixes rust-lang#10005 changelog: `result_large_err`: Fix ICE with uninhabited enums
Additionally:
(I was bored 👻 )