Skip to content
Discussion options

You must be logged in to vote

I went for option 1 and made a reasonable solution IMO. It's straightforward but thought I'd post it here for anyone that might need it.

Separated SkeletonState into two structs, one that internally tracks the Skeleton with the lifetime (SkeletonState), and another that needs a Skeleton reference (DetachedSkeletonState).

Now it looks like this:

pub struct SkeletonState<'a> {
    skeleton: &'a Skeleton,
    internal: DetachedSkeletonState,
}

DetachedSkeletonState is the second "internal" struct that needs Skeleton as a reference for its methods. SkeletonState is kind of like a proxy into DetachedSkeletonState

pub fn pose(&mut self) {
    self.internal.pose(self.skeleton)
}

A library could …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@gak
Comment options

@HackerFoo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by gak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants