Skip to content

Commit 6dbea1f

Browse files
committed
use const_assert!
1 parent f7d7a35 commit 6dbea1f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/core/src/cmp.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ mod impls {
18551855
use crate::hint::unreachable_unchecked;
18561856
use crate::marker::PointeeSized;
18571857
use crate::ops::ControlFlow::{self, Break, Continue};
1858+
use crate::panic::const_assert;
18581859

18591860
macro_rules! partial_eq_impl {
18601861
($($t:ty)*) => ($(
@@ -2002,7 +2003,13 @@ mod impls {
20022003
#[track_caller]
20032004
fn clamp(self, min: Self, max: Self) -> Self
20042005
{
2005-
assert!(min <= max, "min > max. min = {min}, max = {max}");
2006+
const_assert!(
2007+
min <= max,
2008+
"min > max",
2009+
"min > max. min = {min:?}, max = {max:?}",
2010+
min: $t,
2011+
max: $t,
2012+
);
20062013
if self < min {
20072014
min
20082015
} else if self > max {

0 commit comments

Comments
 (0)