Content-Length: 24274 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../vec/../../../../error_codes/./E0527.html

E0527 - Error codes index

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0527

The number of elements in an array or slice pattern differed from the number of elements in the array being matched.

Example of erroneous code:

#![allow(unused)]
fn main() {
let r = &[1, 2, 3, 4];
match r {
    &[a, b] => { // error: pattern requires 2 elements but array
                 //        has 4
        println!("a={}, b={}", a, b);
    }
}
}

Ensure that the pattern is consistent with the size of the matched array. Additional elements can be matched with ..:

#![allow(unused)]
fn main() {
let r = &[1, 2, 3, 4];
match r {
    &[a, b, ..] => { // ok!
        println!("a={}, b={}", a, b);
    }
}
}








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../error/../string/../vec/../../../../error_codes/./E0527.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy