Skip to content

Commit fd078e4

Browse files
committed
Auto merge of #837 - RalfJung:arrays, r=RalfJung
test arrray try_from (interesting const generic usage) Currently fails, see rust-lang/rust#62435 (comment). Blocked on rust-lang/rust#62790.
2 parents 9d14a62 + 3b14567 commit fd078e4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ef1ecbefb8719e408150738664d443a73f757ffd
1+
14890954ce17c44d944eda988c5a64bb4c5ec9eb

tests/run-pass/arrays.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::convert::TryFrom;
2+
13
fn empty_array() -> [u16; 0] {
24
[]
35
}
@@ -33,6 +35,16 @@ fn slice_index() -> u8 {
3335
arr[5]
3436
}
3537

38+
fn try_from() {
39+
const N: usize = 16;
40+
type Array = [u8; N];
41+
let array: Array = [0; N];
42+
let slice: &[u8] = &array[..];
43+
44+
let result = <&Array>::try_from(slice);
45+
assert_eq!(&array, result.unwrap());
46+
}
47+
3648
fn eq() {
3749
const N: usize = 16;
3850
type Array = [u8; N];
@@ -57,6 +69,7 @@ fn main() {
5769
assert_eq!(array_array(), [[5, 4], [3, 2], [1, 0]]);
5870
assert_eq!(array_repeat(), [42; 8]);
5971
assert_eq!(mini_array(), [42]);
72+
try_from();
6073
eq();
6174
debug();
6275
}

0 commit comments

Comments
 (0)