os-rust/tests/ui/borrowck/borrowck-mut-vec-as-imm-slice.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
243 B
Rust
Raw Normal View History

// run-pass
fn want_slice(v: &[isize]) -> isize {
let mut sum = 0;
2015-01-31 12:20:46 -05:00
for i in v { sum += *i; }
sum
}
fn has_mut_vec(v: Vec<isize> ) -> isize {
want_slice(&v)
}
pub fn main() {
assert_eq!(has_mut_vec(vec![1, 2, 3]), 6);
}