Created
August 6, 2013 20:30
-
-
Save MarkJr94/6168319 to your computer and use it in GitHub Desktop.
Weird lifetime issue
This file contains 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
md_ref = line.split_iter(' ') | |
.transform(|s| s.to_owned()) | |
.collect::<~[~str]>()[2] | |
.iter() | |
.collect::<~[char]>() | |
.chunk_iter(2) | |
.transform(|cs| { | |
let s = str::from_chars(cs); | |
println(s); | |
u8::from_str_radix(s, 16).get() | |
}) | |
.collect(); | |
// Error | |
nist.rs:117:29: 122:25 error: borrowed value does not live long enough | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:120 .iter() | |
nist.rs:121 .collect::<~[char]>() | |
nist.rs:122 .chunk_iter(2) | |
nist.rs:117:29: 128:35 note: borrowed pointer must be valid for the method call at 117:29... | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:120 .iter() | |
nist.rs:121 .collect::<~[char]>() | |
nist.rs:122 .chunk_iter(2) | |
... | |
nist.rs:117:29: 123:25 note: ...but borrowed value is only valid for the method call at 117:29 | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:120 .iter() | |
nist.rs:121 .collect::<~[char]>() | |
nist.rs:122 .chunk_iter(2) | |
... | |
nist.rs:117:29: 119:47 error: borrowed value does not live long enough | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:117:29: 122:25 note: borrowed pointer must be valid for the method call at 117:29... | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:120 .iter() | |
nist.rs:121 .collect::<~[char]>() | |
nist.rs:122 .chunk_iter(2) | |
nist.rs:117:29: 121:25 note: ...but borrowed value is only valid for the method call at 117:29 | |
nist.rs:117 md_ref = line.split_iter(' ') | |
nist.rs:118 .transform(|s| s.to_owned()) | |
nist.rs:119 .collect::<~[~str]>()[2] | |
nist.rs:120 .iter() | |
nist.rs:121 .collect::<~[char]>() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment