summaryrefslogtreecommitdiffstats
path: root/vendor/num-traits/src/bounds.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/num-traits/src/bounds.rs
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/num-traits/src/bounds.rs')
-rw-r--r--vendor/num-traits/src/bounds.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/vendor/num-traits/src/bounds.rs b/vendor/num-traits/src/bounds.rs
index c9ff749d2..36e1bbdfb 100644
--- a/vendor/num-traits/src/bounds.rs
+++ b/vendor/num-traits/src/bounds.rs
@@ -8,12 +8,38 @@ use core::{u16, u32, u64, u8, usize};
/// Numbers which have upper and lower bounds
pub trait Bounded {
// FIXME (#5527): These should be associated constants
- /// returns the smallest finite number this type can represent
+ /// Returns the smallest finite number this type can represent
fn min_value() -> Self;
- /// returns the largest finite number this type can represent
+ /// Returns the largest finite number this type can represent
fn max_value() -> Self;
}
+/// Numbers which have lower bounds
+pub trait LowerBounded {
+ /// Returns the smallest finite number this type can represent
+ fn min_value() -> Self;
+}
+
+// FIXME: With a major version bump, this should be a supertrait instead
+impl<T: Bounded> LowerBounded for T {
+ fn min_value() -> T {
+ Bounded::min_value()
+ }
+}
+
+/// Numbers which have upper bounds
+pub trait UpperBounded {
+ /// Returns the largest finite number this type can represent
+ fn max_value() -> Self;
+}
+
+// FIXME: With a major version bump, this should be a supertrait instead
+impl<T: Bounded> UpperBounded for T {
+ fn max_value() -> T {
+ Bounded::max_value()
+ }
+}
+
macro_rules! bounded_impl {
($t:ty, $min:expr, $max:expr) => {
impl Bounded for $t {