-
Notifications
You must be signed in to change notification settings - Fork 37
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
IntoCtx
and FromCtx
for ()
#105
Comments
Sorry for late reply; I think I guess I'm also trying to say it never really came up, but also, it avoids scroll having an "opinion" on serialization (though of course it does). That being said, what do you propose: let mut offset = 0;
bytes.gwrite::<()>(&mut offset)? the value of |
So I ask, because that's a reasonable thing for a rust programmer to say, for example, because zero-sized types are a thing in rust and other languages, but for example, in C, an empty struct has a size of 1, e.g. this prints 1: #include<assert.h>
#include<stdio.h>
struct Foo {
};
int main() {
assert(sizeof(Foo) == 1);
printf("%zu", sizeof(Foo));
return 0;
} However, I think it's probably safe to say that scroll already supports 0-sized structs, e.g., if i derive on an empty struct I assume it would gwrite nothing, and offset would be 0. So I guess that's a roundabout way of saying I think it should be fine to add these implementations? Another random thing, will this fail? let mut bytes: [u8; 0] = [];
bytes.pwrite::<()>(0)?; One could argue it's attempting to write at the first byte offset, i.e., |
Hello, I was wondering if there was a particular reason why
()
does not implementIntoCtx
andFromCtx
?I've created a situation where I have a trait with an associated type that is required to be
<Try>IntoCtx
, but()
would also be valid in my use-case (The associated type is used as the return type of one of the trait functions). I wanted to see if you would be open to adding the trait impls for()
or if I should take a different approach. I'd be happy to add the impls if you have no issue with them being added.Let me know if you need any additional context.
Thanks!
The text was updated successfully, but these errors were encountered: