Created
January 6, 2014 11:46
-
-
Save zokier/8281688 to your computer and use it in GitHub Desktop.
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
fn is_printable_ascii(c: u8) -> bool { | |
c >= 0x20u8 && c < 0x7fu8 | |
} | |
fn main() { | |
// why temporary variable needed? | |
// error: borrowed value does not live long enough | |
let test_data: ~[u8] = std::io::File::open(&Path::new("test_data")).read_to_end(); | |
let _test_data_filtered: ~[u8] = test_data.iter() | |
// why double deref? | |
// error: mismatched types: expected `u8` but found `&&u8` (expected u8 but found &-ptr) | |
.filter(|c| is_printable_ascii(**c)) | |
// why this is needed? | |
// error: mismatched types: expected `~[u8]` but found `~[&u8]` (expected u8 but found &-ptr) | |
.map(|x| *x) | |
.to_owned_vec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment