mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
15 lines
374 B
Rust
15 lines
374 B
Rust
pub fn foo(params: Option<&[&str]>) -> usize {
|
|
params.unwrap().first().unwrap().len()
|
|
}
|
|
|
|
fn main() {
|
|
let name = "Foo";
|
|
let x = Some(&[name]);
|
|
let msg = foo(x);
|
|
//~^ ERROR mismatched types
|
|
//~| expected enum `Option<&[&str]>`
|
|
//~| found enum `Option<&[&str; 1]>`
|
|
//~| expected slice `[&str]`, found array `[&str; 1]`
|
|
assert_eq!(msg, 3);
|
|
}
|