Skip to content

Instantly share code, notes, and snippets.

@Ygg01
Created March 5, 2014 20:35
Show Gist options
  • Save Ygg01/9376034 to your computer and use it in GitHub Desktop.
Save Ygg01/9376034 to your computer and use it in GitHub Desktop.
Memory woes
example.rs:16:18: 16:25 error: `src` does not live long enough
example.rs:16 src: &'a src
^~~~~~~
example.rs:14:40: 18:6 note: reference must be valid for the lifetime &'a as defined on the block at 14:39...
example.rs:14 pub fn make(src : R) -> Lex<'a, R> {
example.rs:15 Lex {
example.rs:16 src: &'a src
example.rs:17 }
example.rs:18 }
example.rs:14:40: 18:6 note: ...but borrowed value is only valid for the block at 14:39
example.rs:14 pub fn make(src : R) -> Lex<'a, R> {
example.rs:15 Lex {
example.rs:16 src: &'a src
example.rs:17 }
example.rs:18 }
example.rs:21:26: 21:34 error: cannot borrow immutable dereference of `&`-pointer `*self.src` as mutable
example.rs:21 let line = match self.src.read_line() {
^~~~~~~~
example.rs:27:19: 27:23 error: `line` does not live long enough
example.rs:27 let brw = line.as_slice();
^~~~
example.rs:20:47: 29:6 note: reference must be valid for the lifetime &'a as defined on the block at 20:46...
example.rs:20 pub fn results(&mut self) -> Transfer<'a> {
example.rs:21 let line = match self.src.read_line() {
example.rs:22 Ok(line) => {
example.rs:23 line
example.rs:24 },
example.rs:25 _ => ~""
...
example.rs:20:47: 29:6 note: ...but borrowed value is only valid for the block at 20:46
example.rs:20 pub fn results(&mut self) -> Transfer<'a> {
example.rs:21 let line = match self.src.read_line() {
example.rs:22 Ok(line) => {
example.rs:23 line
example.rs:24 },
example.rs:25 _ => ~""
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment