Skip to content

Instantly share code, notes, and snippets.

@tnibert
Created July 2, 2025 10:56
Show Gist options
  • Select an option

  • Save tnibert/802c7d37d737f12f269ff008dbe5efb7 to your computer and use it in GitHub Desktop.

Select an option

Save tnibert/802c7d37d737f12f269ff008dbe5efb7 to your computer and use it in GitHub Desktop.
dependency injection with lifetimes
pub struct Sprite <'a> {
x: i32,
y: i32,
velocity: i32,
pub object: Object <'a>,
}
impl <'a> Sprite <'a> {
pub fn new(x: i32, y: i32, velocity: i32, object: Object<'a>) -> Sprite<'a>{
Self {
x: x,
y: y,
velocity: velocity,
object: object,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment