]> git.lizzy.rs Git - rust.git/commitdiff
test some const-generic-using methods
authorRalf Jung <post@ralfj.de>
Sat, 13 Jul 2019 08:23:40 +0000 (10:23 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 13 Jul 2019 08:25:04 +0000 (10:25 +0200)
tests/run-pass/arrays.rs
tests/run-pass/arrays.stdout [new file with mode: 0644]

index 469dde3091eb25993c7b4d69bc5f4fb12f437444..d374ccf25354a8c9d21768a30addcbc423f1cad9 100644 (file)
@@ -33,6 +33,21 @@ fn slice_index() -> u8 {
     arr[5]
 }
 
+fn eq() {
+    const N: usize = 16;
+    type Array = [u8; N];
+    let array1: Array = [0; N];
+    let array2: Array = [0; N];
+    let array3: Array = [1; N];
+    assert_eq!(array1, array2);
+    assert_ne!(array1, array3);
+}
+
+fn debug() {
+    let array = [0u8, 42, 13, 71];
+    println!("{:?}", array);
+}
+
 fn main() {
     assert_eq!(empty_array(), []);
     assert_eq!(index_unsafe(), 20);
@@ -42,4 +57,6 @@ fn main() {
     assert_eq!(array_array(), [[5, 4], [3, 2], [1, 0]]);
     assert_eq!(array_repeat(), [42; 8]);
     assert_eq!(mini_array(), [42]);
+    eq();
+    debug();
 }
diff --git a/tests/run-pass/arrays.stdout b/tests/run-pass/arrays.stdout
new file mode 100644 (file)
index 0000000..6c3cefa
--- /dev/null
@@ -0,0 +1 @@
+[0, 42, 13, 71]