Skip to content

Commit

Permalink
add: list of methods to be implemented as of current state of discussion
Browse files Browse the repository at this point in the history
Signed-off-by: benaryorg <binary@benary.org>
  • Loading branch information
benaryorg committed Aug 11, 2016
1 parent 6193dd8 commit 39aff7c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions text/0000-duration-checked-sub.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# Summary
[summary]: #summary

This RFC adds `checked_sub()` already known from various primitive types to the
`Duration` *struct*.
This RFC adds the `checked_*` methods already known from primitives like
`usize` to `Duration`.

# Motivation
[motivation]: #motivation
Expand Down Expand Up @@ -42,6 +42,9 @@ fn render() {
}
```

Of course it is also suitable to not introduce `panic!()`s when adding
`Duration`s.

# Detailed design
[design]: #detailed-design

Expand Down Expand Up @@ -73,21 +76,27 @@ impl Duration {
}
```

The same accounts for all other added methods, namely:

- `checked_add()`
- `checked_sub()`
- `checked_mul()`
- `checked_div()`

# Drawbacks
[drawbacks]: #drawbacks

This proposal adds another `checked_*` method to *libstd*.
One could ask why no `CheckedSub` trait if there is a `Sub` trait.
`None`.

# Alternatives
[alternatives]: #alternatives

The alternatives are simply not doing this and forcing the programmer to code
the check on their behalf.
This is not what you want.

# Unresolved questions
[unresolved]: #unresolved-questions

Should all functions of the form
`(checked|saturating|overflowing|wrapping)_(add|sub|mul|div)` be added?
`None`.

0 comments on commit 39aff7c

Please sign in to comment.