Skip to content
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

Closed
mitsuhiko opened this issue Oct 18, 2012 · 3 comments
Closed

Add Zero Trait #3797

mitsuhiko opened this issue Oct 18, 2012 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@mitsuhiko
Copy link
Contributor

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 on Option.

@bblum
Copy link
Contributor

bblum commented Oct 19, 2012

+1. Needs static methods (i'm not sure what the status of those is).

@thestinger
Copy link
Contributor

There's now a num::Zero trait thanks to #4238.

@ghost ghost assigned catamorphism Jan 3, 2013
catamorphism added a commit to catamorphism/rust that referenced this issue Jan 3, 2013
@catamorphism
Copy link
Contributor

Added get_zero in 1f1e7e9 -- so this seems to be done.

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
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants