mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
adjust for slice pattern changes
This commit is contained in:
@@ -6,11 +6,11 @@ fn main() {
|
||||
let mut result = vec!();
|
||||
loop {
|
||||
x = match *x {
|
||||
[1, n, 3, ref rest..] => {
|
||||
[1, n, 3, ref rest @ ..] => {
|
||||
result.push(n);
|
||||
rest
|
||||
}
|
||||
[n, ref rest..] => {
|
||||
[n, ref rest @ ..] => {
|
||||
result.push(n);
|
||||
rest
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ fn main() {
|
||||
}, 42_usize);
|
||||
|
||||
assert_eq!(match [0u8; 1024] {
|
||||
[1, _..] => 0_usize,
|
||||
[0, _..] => 1_usize,
|
||||
[1, ..] => 0_usize,
|
||||
[0, ..] => 1_usize,
|
||||
_ => 2_usize
|
||||
}, 1_usize);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
fn main() {
|
||||
let out = bar("baz", "foo");
|
||||
let [a, xs.., d] = out;
|
||||
let [a, xs @ .., d] = out;
|
||||
assert_eq!(a, "baz");
|
||||
assert_eq!(xs, ["foo", "foo"]);
|
||||
assert_eq!(d, "baz");
|
||||
|
||||
@@ -9,7 +9,7 @@ fn foldl<T, U, F>(values: &[T],
|
||||
U: Clone+Debug, T:Debug,
|
||||
F: FnMut(U, &T) -> U,
|
||||
{ match values {
|
||||
&[ref head, ref tail..] =>
|
||||
&[ref head, ref tail @ ..] =>
|
||||
foldl(tail, function(initial, head), function),
|
||||
&[] => {
|
||||
let res = initial.clone(); res
|
||||
@@ -25,7 +25,7 @@ fn foldr<T, U, F>(values: &[T],
|
||||
F: FnMut(&T, U) -> U,
|
||||
{
|
||||
match values {
|
||||
&[ref head.., ref tail] =>
|
||||
&[ref head @ .., ref tail] =>
|
||||
foldr(head, function(tail, initial), function),
|
||||
&[] => {
|
||||
let res = initial.clone(); res
|
||||
|
||||
Reference in New Issue
Block a user