Last active
August 29, 2015 14:21
-
-
Save steveklabnik/1da807447e3f0e465803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/lib.rs b/src/lib.rs | |
| index 4caaa9d..853035b 100644 | |
| --- a/src/lib.rs | |
| +++ b/src/lib.rs | |
| @@ -28,19 +28,21 @@ pub extern fn couchquickview() { | |
| let (tx, rx) = mpsc::channel(); | |
| - for l in 0..lines.len() { | |
| + let len = lines.len(); | |
| + | |
| + for l in lines { | |
| let (data, tx) = (data.clone(), tx.clone()); | |
| thread::spawn(move || { | |
| let mut data = data.lock().unwrap(); | |
| *data += 1; | |
| - println!("LINE: {}", lines[l].clone()); | |
| + println!("LINE: {}", l); | |
| tx.send(()); | |
| }); | |
| } | |
| - for s in 0..lines.len() { | |
| + for s in 0..len { | |
| rx.recv(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| src/lib.rs:24:28: 24:32 error: `body` does not live long enough | |
| src/lib.rs:24 let lines: Vec<&str> = body.split("\n").collect(); | |
| ^~~~ | |
| note: reference must be valid for the static lifetime... | |
| src/lib.rs:22:34: 49:2 note: ...but borrowed value is only valid for the block suffix following statement 4 at 22:33 | |
| src/lib.rs:22 let mut body = String::new(); | |
| src/lib.rs:23 res.read_to_string(&mut body).unwrap(); | |
| src/lib.rs:24 let lines: Vec<&str> = body.split("\n").collect(); | |
| src/lib.rs:25 println!("LINE 1: {}", lines.len()); | |
| src/lib.rs:26 | |
| src/lib.rs:27 let data = Arc::new(Mutex::new(0u32)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment