-
Notifications
You must be signed in to change notification settings - Fork 149
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
Rename Sol*
traits' from_rust
method to new
and remove to_rust
#90
Comments
to rust is currently used to implement encoding. However, this currently requires cloning all the data -_- The fundamental issue is that encoding a tuple takes
|
If we can implement the trait for trait Something {
fn f(&self);
}
impl<T: Something> Something for &T {
fn f(&self) {
T::f(*self)
}
}
impl Something for u8 {
fn f(&self) {}
}
impl Something for () {
fn f(&self) {}
}
impl<T: Something> Something for (T,) {
fn f(&self) {}
}
impl<T: Something, U: Something> Something for (T, U) {
fn f(&self) {}
}
fn main() {
Something::f(&(0u8, ()));
Something::f(&(0u8, &()));
Something::f(&(&0u8, &()));
Something::f(&&(0u8, ()));
Something::f(&&(0u8, &()));
Something::f(&&(&0u8, &()));
Something::f(&&(&&&&&&&&&&&&0u8, &&&&()));
} |
it's not the trait that's the problem. it's the defintion of
|
we need to find some way to write the bound on |
We might be able to avoid cloning by adding |
pretty sure that's not sound, or is sound only as an implementation detail. default layout has no guarantees |
Yes, the default layout has no guarantees other than the basic soundness stuff, but tuples also use the default layout except for the unit type, but that doesn't matter because empty structs are not allowed here |
Here's some code to verify that it's sound |
yeah, but we have no guarantee that it remains sound in any given future version, or on any architectures we're not checking. Hence why i say "sound as an implementation detail" |
Hmm yeah you're not allowed to do any casting with the default Rust repr, even if the defs are identical. So we can't do that with the default tuples, but we could if we defined a second struct for the fields / generic Tuple struct? Idk |
we could actually have all sol structs be
|
this approach? |
removing |
for other users to_rust like |
No description provided.
The text was updated successfully, but these errors were encountered: