Created
November 21, 2014 15:04
-
-
Save Geal/aa302032809b4b2bc6bc 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
| fn main() { | |
| let a = |input: &[u8]| { | |
| input.slice_from(1) | |
| }; | |
| println!("a: {}", a("abc".as_bytes())); | |
| } |
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
| closure2.rs:3:11: 3:24 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements | |
| closure2.rs:3 input.slice_from(1) | |
| ^~~~~~~~~~~~~ | |
| closure2.rs:5:21: 5:40 note: first, the lifetime cannot outlive the call at 5:20... | |
| closure2.rs:5 println!("a: {}", a("abc".as_bytes())); | |
| ^~~~~~~~~~~~~~~~~~~ | |
| note: in expansion of format_args! | |
| <std macros>:2:23: 2:77 note: expansion site | |
| <std macros>:1:1: 3:2 note: in expansion of println! | |
| closure2.rs:5:3: 5:42 note: expansion site | |
| closure2.rs:5:21: 5:40 note: ...so type `&[u8]` of expression is valid during the expression | |
| closure2.rs:5 println!("a: {}", a("abc".as_bytes())); | |
| ^~~~~~~~~~~~~~~~~~~ | |
| note: in expansion of format_args! | |
| <std macros>:2:23: 2:77 note: expansion site | |
| <std macros>:1:1: 3:2 note: in expansion of println! | |
| closure2.rs:5:3: 5:42 note: expansion site | |
| closure2.rs:3:5: 3:10 note: but, the lifetime must be valid for the expression at 3:4... | |
| closure2.rs:3 input.slice_from(1) | |
| ^~~~~ | |
| closure2.rs:3:5: 3:10 note: ...so that auto-reference is valid at the time of borrow | |
| closure2.rs:3 input.slice_from(1) | |
| ^~~~~ | |
| error: aborting due to previous error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment