Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe a dumb question, clone or copy? #115

Closed
andrewchambers opened this issue May 3, 2018 · 2 comments
Closed

Maybe a dumb question, clone or copy? #115

andrewchambers opened this issue May 3, 2018 · 2 comments
Labels

Comments

@andrewchambers
Copy link

I am trying to copy a subvalue out of an rpc params message, and then encode it as a new standalone message (which is then written to disk). What would be the correct way to clone or copy one of my own structs into a new message/segment? Alternatively, is it safe to have a single segment being used by two messages?

@andrewchambers andrewchambers changed the title Maybe dumb question, clone or copy? Maybe a dumb question, clone or copy? May 3, 2018
@zombiezen
Copy link
Contributor

If you set a pointer field to an object in a different message, the object will be copied automatically into the message. This is perhaps not documented as well as it should be, but the behavior is guaranteed.

@andrewchambers
Copy link
Author

Thanks for the explanation, I really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants