Skip to content

Instantly share code, notes, and snippets.

@gong023
Created September 28, 2014 12:31
Show Gist options
  • Save gong023/f35fe885b83544c220a7 to your computer and use it in GitHub Desktop.
Save gong023/f35fe885b83544c220a7 to your computer and use it in GitHub Desktop.
--- Type 'make test' to test library
--- Built internal test runner
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
src/test.rs:18:23: 18:45 error: borrowed value does not live long enough
src/test.rs:18 let initial_vec = __::Vect::new(vec_int).initial(2u);
^~~~~~~~~~~~~~~~~~~~~~
src/test.rs:16:23: 29:2 note: reference must be valid for the block at 16:22...
src/test.rs:16 fn test_vec_initial() {
src/test.rs:17 let vec_int = vec!(1i, 1i, 2i);
src/test.rs:18 let initial_vec = __::Vect::new(vec_int).initial(2u);
src/test.rs:19 // assert_eq!(2u, initial_vec);
src/test.rs:20 for x in initial_vec.iter() {
src/test.rs:21 assert_eq!(1i, **x)
...
src/test.rs:18:9: 18:57 note: ...but borrowed value is only valid for the statement at 18:8; consider using a `let` binding to increase its lifetime
src/test.rs:18 let initial_vec = __::Vect::new(vec_int).initial(2u);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
fn test_vec_initial() {
let vec_int = vec!(1i, 1i, 2i);
// let initial_vec = __::Vect::new(vec_int).initial(2u);
// assert_eq!(2u, initial_vec);
for x in __::Vect::new(vec_int).initial(2u).iter() {
assert_eq!(1i, **x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment