Created
July 2, 2025 10:56
-
-
Save tnibert/802c7d37d737f12f269ff008dbe5efb7 to your computer and use it in GitHub Desktop.
dependency injection with lifetimes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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