Skip to content

Conversation

@silverjam
Copy link
Contributor

@silverjam silverjam commented May 12, 2020

So we can have a way to easily detach message objects from their source lifetimes, implement clone.
This enables us to implement something like:

https://gist.github.com/silverjam/43b543c58f37cb39575b01487f10779e

Jason Mobarak added 2 commits May 12, 2020 15:53
Copy link
Contributor

@jbangelo jbangelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there are any other traits we'd like to automatically derive for all messages? List: https://doc.rust-lang.org/stable/rust-by-example/trait/derive.html

@silverjam
Copy link
Contributor Author

silverjam commented May 13, 2020

@jbangelo nothing jumps out at me, except maybe we should be Copy instead of Clone? I picked .clone() since it's more explicit, and SBP structs can be 256 bytes (not sure what the threshold should be for picking copy over clone w.r.t. memory size). In support of copy: SBP messages have a fixed maximum size, and we don't contain anything that's not copy-able. Not in support of copy: structs can be large-ish.

@jbangelo
Copy link
Contributor

@silverjam I think the log message contains a string (others might as well), which would prevent deriving Copy for it. I think only deriving Clone is probably good enough. Given the variable size of the messages I don't think it's in the spirit of the Copy trait too potentially be copying 255 bytes.

@silverjam silverjam merged commit 3305734 into master May 13, 2020
@silverjam silverjam deleted the silverjam/rust-derive-clone branch May 13, 2020 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants