]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-7784.rs
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / issues / issue-7784.rs
1 // run-pass
2
3 use std::ops::Add;
4
5 fn foo<T: Add<Output=T> + Clone>([x, y, z]: [T; 3]) -> (T, T, T) {
6     (x.clone(), x.clone() + y.clone(), x + y + z)
7 }
8 fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] {
9     [a, b, b, a]
10 }
11
12 fn main() {
13     assert_eq!(foo([1, 2, 3]), (1, 3, 6));
14
15     let [a, b, c, d] = bar("foo", "bar");
16     assert_eq!(a, "foo");
17     assert_eq!(b, "bar");
18     assert_eq!(c, "bar");
19     assert_eq!(d, "foo");
20
21     let [a, _, _, d] = bar("baz", "foo");
22     assert_eq!(a, "baz");
23     assert_eq!(d, "baz");
24
25     let out = bar("baz", "foo");
26     let [a, xs @ .., d] = out;
27     assert_eq!(a, "baz");
28     assert_eq!(xs, ["foo", "foo"]);
29     assert_eq!(d, "baz");
30 }