“borrowed value does not live long enough” when using the builder pattern
Here’s a minimal reproduction: #[derive(Debug)] pub struct Canvas; impl Canvas { fn new() -> Self { Canvas } fn color(&self) -> &Canvas { self } } fn main() { let mut canvas = Canvas::new().color(); // 1 ^~~~~~~~~~~~~ // 2 ^~~~~ println!(“{:?}”, canvas); } Rust 2015 error[E0597]: borrowed value does not live long enough –> src/main.rs:15:22 … Read more