File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( slice_patterns) ]
2
+
3
+ pub struct History < ' a > { pub _s : & ' a str }
4
+
5
+ impl < ' a > History < ' a > {
6
+ pub fn get_page ( & self ) {
7
+ for s in vec ! [ "1|2" . to_string( ) ] . into_iter ( ) . filter_map ( |ref line| self . make_entry ( line) ) {
8
+ //~^ ERROR borrowed value does not live long enough
9
+ println ! ( "{:?}" , s) ;
10
+ }
11
+ }
12
+
13
+ fn make_entry ( & self , s : & ' a String ) -> Option < & str > {
14
+ let parts: Vec < _ > = s. split ( '|' ) . collect ( ) ;
15
+ println ! ( "{:?} -> {:?}" , s, parts) ;
16
+
17
+ if let [ commit, ..] = & parts[ ..] { Some ( commit) } else { None }
18
+ }
19
+ }
20
+
21
+ fn main ( ) {
22
+ let h = History { _s : "" } ;
23
+ h. get_page ( ) ;
24
+ }
Original file line number Diff line number Diff line change
1
+ error[E0597]: borrowed value does not live long enough
2
+ --> $DIR/issue-26619.rs:7:66
3
+ |
4
+ LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) {
5
+ | ^^^^^^^^ -- temporary value needs to live until here
6
+ | | |
7
+ | | temporary value dropped here while still borrowed
8
+ | temporary value does not live long enough
9
+
10
+ error: aborting due to previous error
11
+
12
+ For more information about this error, try `rustc --explain E0597`.
You can’t perform that action at this time.
0 commit comments