We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
const
i32::signum
1 parent bd899d0 commit f6611dbCopy full SHA for f6611db
src/test/run-pass/const-int-sign.rs
@@ -1,11 +1,21 @@
1
+#![feature(const_int_sign)]
2
+
3
const NEGATIVE_A: bool = (-10i32).is_negative();
4
const NEGATIVE_B: bool = 10i32.is_negative();
-const POSITIVE_A: bool= (-10i32).is_positive();
-const POSITIVE_B: bool= 10i32.is_positive();
5
+const POSITIVE_A: bool = (-10i32).is_positive();
6
+const POSITIVE_B: bool = 10i32.is_positive();
7
8
+const SIGNUM_POS: i32 = 10i32.signum();
9
+const SIGNUM_NIL: i32 = 0i32.signum();
10
+const SIGNUM_NEG: i32 = (-42i32).signum();
11
12
fn main() {
13
assert!(NEGATIVE_A);
14
assert!(!NEGATIVE_B);
15
assert!(!POSITIVE_A);
16
assert!(POSITIVE_B);
17
18
+ assert_eq!(SIGNUM_POS, 1);
19
+ assert_eq!(SIGNUM_NIL, 0);
20
+ assert_eq!(SIGNUM_NEG, -1);
21
}
0 commit comments