-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 Zero Trait #3797
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Comments
+1. Needs static methods (i'm not sure what the status of those is). |
There's now a |
Added |
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this issue
Aug 10, 2024
Don't panic on `miri_print_borrow_state()` under `-Zmiri-disable-stacked-borrows`. Fixes rust-lang#3459 Instead, just print "attempted to print borrow state, but no borrow state is being tracked" directly to ~~stdout~~ stderr and return successfully. Alternately, the diagnostic machinery could be used to print a structured error/warning. (Does not address the comment about nothing being printed for `miri_print_borrow_state` with `alloc_id = 0`)
RalfJung
pushed a commit
to RalfJung/rust
that referenced
this issue
Aug 18, 2024
Don't panic on `miri_print_borrow_state()` under `-Zmiri-disable-stacked-borrows`. Fixes rust-lang#3459 Instead, just print "attempted to print borrow state, but no borrow state is being tracked" directly to ~~stdout~~ stderr and return successfully. Alternately, the diagnostic machinery could be used to print a structured error/warning. (Does not address the comment about nothing being printed for `miri_print_borrow_state` with `alloc_id = 0`)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The core or standard library could probably use a Zero trait that allows certain types to provide a zero value. For instance integers would zero to "0", floats to "0.0", strings to an empty string, bools to false, Options probably to None etc.
What exact types make sense to zero or not is most likely up to discussion. Related to that it might be useful to have a
get_or_zero
onOption
.The text was updated successfully, but these errors were encountered: