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.
tests/ui/numbers-arithmetic/uint.rs
usize-base.rs
1 parent 0ee66e3 commit a6dce17Copy full SHA for a6dce17
tests/ui/numbers-arithmetic/uint.rs
tests/ui/numbers-arithmetic/usize-base.rs
@@ -0,0 +1,25 @@
1
+//! Tests basic `usize` functionality
2
+
3
+//@ run-pass
4
5
+pub fn main() {
6
+ // Literal matches assignment type
7
+ let a: usize = 42usize;
8
+ // Literal cast
9
+ let b: usize = 42 as usize;
10
+ // Literal type inference from assignment type
11
+ let c: usize = 42;
12
+ // Assignment type inference from literal (and later comparison)
13
+ let d = 42usize;
14
+ // Function return value type inference
15
+ let e = return_val();
16
17
+ assert_eq!(a, b);
18
+ assert_eq!(a, c);
19
+ assert_eq!(a, d);
20
+ assert_eq!(a, e);
21
+}
22
23
+fn return_val() -> usize {
24
+ 42
25
0 commit comments