# Please can we add a basic num trait?

**URL:** <https://internals.rust-lang.org/t/please-can-we-add-a-basic-num-trait/16449>\
**Category:** libs\
**Created:** [April 10, 2022, 3:51pm UTC](https://internals.rust-lang.org/t/please-can-we-add-a-basic-num-trait/16449 "2022-04-10T15:51:58Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [April 10, 2022, 11:38pm UTC](https://internals.rust-lang.org/t/please-can-we-add-a-basic-num-trait/16449/9 "2022-04-10T23:38:08Z")

</div>

> [@gilescope](#):
>
> In the spirit of baby steps, what's the smallest trait we could have? Would having MIN, MAX, and BITS as a single trait be a first baby step?

Something like a `num::Bounded` with `MIN` & `MAX`, maybe? Probably the most useful thing to see would be examples of code that could take advantage of such a trait, to answer questions like "what about `num::BigUint` that has `MIN` but not `MAX`?".

`BITS` is arguably weird in generic code, since one could say that `NonZeroU8` should be 7.994353... bits.

Hmm, maybe there's a nice holistic piece here by having a trait like `num::SaturatingFrom` (as discussed, IIRC, in [https://github.com/rust-lang/rfcs/pull/2484](https://github.com/rust-lang/rfcs/pull/2484)) and a corresponding trait with `MIN` & `MAX` that says what the range into which it saturates is.

---

_[View the full topic](https://internals.rust-lang.org/t/please-can-we-add-a-basic-num-trait/16449)._
