You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using rust-sfml and I'd like to encapsulate all my rendering into a Renderer struct that has methods like handle_events(), draw(), etc., so none of the rest of my code needs to worry about rendering.
https://gist.github.com/dfannius/963d17ca466ceb00373dfbb680a862e1 shows a minimal example of the issue I'm running into. I'd like the Renderer to do all its resource acquisition on construction, but if I create a Font inside new, it doesn't live long enough. I'd like to create it on the heap and give Text an Rc, but Text as currently implemented doesn't support that.
As it is, I can pass a &Font into the constructor, but that just moves the problem up one level (the Renderer can't live outside of the enclosing function).
Anyway, I don't know what the best solution is, but that is my use case.
The text was updated successfully, but these errors were encountered:
I'm using rust-sfml and I'd like to encapsulate all my rendering into a Renderer struct that has methods like handle_events(), draw(), etc., so none of the rest of my code needs to worry about rendering.
https://gist.github.com/dfannius/963d17ca466ceb00373dfbb680a862e1 shows a minimal example of the issue I'm running into. I'd like the Renderer to do all its resource acquisition on construction, but if I create a Font inside
new
, it doesn't live long enough. I'd like to create it on the heap and give Text an Rc, but Text as currently implemented doesn't support that.As it is, I can pass a &Font into the constructor, but that just moves the problem up one level (the Renderer can't live outside of the enclosing function).
Anyway, I don't know what the best solution is, but that is my use case.
The text was updated successfully, but these errors were encountered: