2015-01-08 11:02:42 +00:00
|
|
|
pub fn foo(params: Option<&[&str]>) -> usize {
|
2015-01-02 07:53:35 +00:00
|
|
|
params.unwrap().first().unwrap().len()
|
2014-09-11 22:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let name = "Foo";
|
2015-02-02 02:53:25 +00:00
|
|
|
let x = Some(&[name]);
|
2015-01-08 16:39:17 +00:00
|
|
|
let msg = foo(x);
|
2019-09-06 18:21:26 +00:00
|
|
|
//~^ ERROR mismatched types
|
2020-09-02 07:40:56 +00:00
|
|
|
//~| expected enum `Option<&[&str]>`
|
|
|
|
//~| found enum `Option<&[&str; 1]>`
|
2019-11-15 07:45:30 +00:00
|
|
|
//~| expected slice `[&str]`, found array `[&str; 1]`
|
2014-09-11 22:54:44 +00:00
|
|
|
assert_eq!(msg, 3);
|
|
|
|
}
|