Struct with reference to parent(owner) struct

I am looking for advice on a modelling a ownership relation in Rust.

For context, this is for an implementation of a version control system. A Repository needs to have a Status but deriving a Status requires calling on methods from Repository .

I've created a minimal example here: The codebase I'm actually working on is also available here:

The proper modeling of the domain would be for a Repository to have a Status field. But because some Status methods call Repository methods, I have had to make Repository a field in Status instead.(which I've marked HACKY in the gist above)

This means that the struct that owns Repository now owns a Status and methods in the parent struct call Repository methods look like self.status.repo.some_repository_method() .

I should also point out that my modelling might have been a bit prejudiced by a Ruby implementation that I am referencing: -- in this project Repository passes self to the child Status which uses that to call on Repository methods.

When posting in several places, you should post those links, to avoid duplication of effort and enable people to post from a fully informed perspective. Here's the reddit link:

Perhaps you can move the shared fields of Status and Repository into an Arc and put it in both.