-
Notifications
You must be signed in to change notification settings - Fork 105
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
Support deriving AsBytes on types with type parameters #10
Comments
Would it be possible to have a special case if the type parameter has a bound on |
I'm not sure what the relevance of |
I did like to have types like #[derive(FromBytes)]
struct Foo<B: ByteOrder> {
a: U32<B>,
b: U32<B>,
} to work with both little endian and big endian using the same type definition. However the restriction of not having any type parameters when deriving FromBytes prevents this. I thought it did be easier to allow FromBytes just for type parameters bound by ByteOrder than implementing the general case. |
That code should work fine. It's just |
I see. Adding |
I wonder if single field |
They could, but I'm not sure what the point would be. If you're considering adding
|
@joshlf I'm interested in working on this. Would you be interested in seeing an exploration of any of the following?
|
Thanks for your interest! The type-level representation of size and alignment is what we'd consider. I'll warn you that the design space there is large and there are lots of thorns, and since any traits introduced will be part of our public API, we'll be very nitpicky about the exact design. That said, it would be great to have some experimentation with this at a minimum, and if you're willing to put up with our nitpickiness, then a full implementation would obviously be very welcome! For inspiration, see: #1316 (comment) (although I haven't looked closely at those examples, and I'm not sure whether they address all of our needs). |
Migrated from https://fxbug.dev/100235
In order to accomplish this, we need to be able to emit an impl which is bounded by a const expr, which requires the unstable feature
generic_const_exprs
. This issue is blocked until that feature is stabilized.The text was updated successfully, but these errors were encountered: