I have much to learn with Rust still, I’m experimenting with the sdl2 rust crate. I’d like to write a function that returns a newly created Texture. These are bound to the lifetime of the Canvas they are created for, so I figured a function that took a canvas reference as an argument and returned a new Surface sharing its lifetime?
I cannot determine the function signature that will compile. This is likely tricky due to the generic types and lifetime references I’ll need to make. The primary sdl2 classes are the Canvas and Texture.
I believe the signature should look like: (the compiler disagrees)
fn loadtex<'r, T: Window>(canvas: & Canvas<T>) -> &Texture
One of my problems is that Canvas requires an additional trait for the
create_texture function I’m wanting, so I need to specify something, but can only find a struct that implements the function I want. Window, I am told, is not a trait.