2014-09-11 17:54:44 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-01-08 05:02:42 -06:00
|
|
|
pub fn foo(params: Option<&[&str]>) -> usize {
|
2015-01-02 01:53:35 -06:00
|
|
|
params.unwrap().first().unwrap().len()
|
2014-09-11 17:54:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let name = "Foo";
|
2015-02-01 20:53:25 -06:00
|
|
|
let x = Some(&[name]);
|
2015-01-08 10:39:17 -06:00
|
|
|
let msg = foo(x);
|
2015-01-12 00:01:44 -06:00
|
|
|
//~^ ERROR mismatched types
|
2016-04-20 13:42:13 -05:00
|
|
|
//~| expected type `std::option::Option<&[&str]>`
|
|
|
|
//~| found type `std::option::Option<&[&str; 1]>`
|
|
|
|
//~| expected slice, found array of 1 elements
|
2014-09-11 17:54:44 -05:00
|
|
|
assert_eq!(msg, 3);
|
|
|
|
}
|