Am I over-generalizing to say the following? These seem like good guidelines to me based on my limited experience so far in writing Rust code. While I know there are situations in which these do not apply,
it seems that following these typically reduces ownership issues in my code.
Collections should own their heap data rather than hold references to heap data owned elsewhere.
For example, struct fields that are strings should use
Pass references to heap data to functions rather than transferring ownership.
For example, a parameter that accepts string data should have the type
In functions that create and return heap data, transfer ownership to the caller.
For example, return