“borrowed value does not live long enough” when using the builder pattern
I have the following code: pub struct Canvas<'a> { width: isize, height: isize, color: Color, surface: Surface, texture: Texture, renderer: &'a Renderer, } impl<'a> Canvas<'a> { pub fn new(width: isize, height: isize, renderer: &'a Renderer) -> Canvas<'a> { let color = Color::RGB(0, 30, 0); let mut surface = core::create_surface(width, height); let texture = Canvas::gen_texture(&mut surface, width, height, color, renderer); Canvas { width: width, height: height, color: color, surface: surface, texture: texture, renderer: renderer, } } pub fn color(&mut self, color: Color) -> &mut Canvas<'a> {