News for hackers. Stuff that matters.
Re:Rust's 2017 Roadmap by general_pizza on Tuesday February 07, 2017 @01:12PM (#13591278)
Interesting. Out of curiosity, what's a case where tmp = a.b(); tmp.c() works but a.b().c() doesn't? I'm still learning rust and the online book's Methods chapter doesn't say anything about such restrictions.
Re:Rust's 2017 Roadmap by steveklabnik on Tuesday February 07, 2017 @02:25PM (#13591869)
It happens if b() returns an owned value that c() returns a reference to. In that case,

  a.b().c()
b here is temporary, and so is freed at the end of the line, making the return of c dangling

  let temp = a.b();
  temp.c();
Now that the return of b() is not temporary, it will last to the end of the scope and so c is fine.