-
Notifications
You must be signed in to change notification settings - Fork 228
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
Custom bound for parity-util-mem-derive #331
Comments
Not sure I follow, what does the derived impl look like with |
You mean something like #255? |
Yep sorry, forgot to expand. Obviously, actual type in structure gets bounded, not generic argument. So: impl<B> MallocSizeOf for Transaction<B> where B::Hash: MallocSizeOf { .. } |
Not really. It has nothing to do with actual calculations, just with where section bounds generation. |
Maybe we can have something like this paritytech/parity-scale-codec#40? |
Yes, seems like the right direction. I don't really see the point of making stupid bounds on all generic arguments. For example, this thing: #[derive(MallocSizeOf)]
struct Foo<B> {
member: PhantomData<B>
} could go just without any bounds on B, because |
This is a long-standing issue in rustc rust-lang/rust#26925 that will hopefully be resolved with chalk, but it may take a while (as you can see the issue is 5 years old). |
Imagine the struct:
#[parity_util_mem::MallocSizeOf]
will fail miserably there, because it will add something like that:what instead would be cool is be able to declare this:
which expands to:
(so that concrete type used in structure got bounded, not generic argument)
if any
#[custom_ty_bound]
declared in the structure, default ones (B: MallocSizeOf
) should not be addedThe text was updated successfully, but these errors were encountered: