New to rust, I'm trying my hand at a simple sdl project.
I want to create a Sprite struct to hold the surface & texture to display a simple image.
My attempt so far:
pub struct Sprite<'a> {
    //surface : sdl2::surface::Surface<'a>,
    texture : sdl2::render::Texture<'a>,
}
impl Sprite<'_> {
    pub fn new<'a, P: AsRef<std::path::Path>>(
        canvas: &mut sdl2::render::WindowCanvas,
        path: P
        ) -> Result<Sprite<'a>, String>
    {
        let surface = sdl2::surface::Surface::load_bmp(path)?;
        let texture_creator = canvas.texture_creator();
        let texture = texture_creator.create_texture_from_surface(&surface).unwrap();
        Ok(Sprite {
            //surface,
            texture,
        })
    }
}
Sadly, texture_creator gets borrowed by the create_texture_from_surface call which gives me:
error[E0515]: cannot return value referencing local variable
texture_creator
I don't know how to work around this issue and need help to understand it
