Skip to content
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

MultiIndex prefix and sub_prefix working incorrectly when using a triple element tuple as IK #730

Closed
y-pakorn opened this issue Jun 1, 2022 · 1 comment

Comments

@y-pakorn
Copy link
Contributor

y-pakorn commented Jun 1, 2022

Current prefix and sub_prefix of MultiIndex don't correctly use Prefix and SubPrefix type bound, resulting in unexpected behavior when using struct that utilize all of prefix, sub prefix, suffix, super suffix. For example, triple element tuple.

let f: MultiIndex<(u32, u64, u128), (u32, u64, u128), u128> =
    MultiIndex::new(|e| (e.0, e.1, e.2), "pk", "idx");

f.prefix((1, 2)); // expected tuple `(u32, u64, u128)` found tuple `(u32, u64)`
f.sub_prefix(1u32); //  expected tuple `(u32, u64)` found type `u32`

Original interface

pub fn prefix(&self, p: IK) -> Prefix<PK, T, PK>;
pub fn sub_prefix(&self, p: IK::Prefix) -> Prefix<PK, T, (IK::Suffix, PK)>;

Correct Interface

pub fn prefix(&self, p: IK::Prefix) -> Prefix<PK, T, (IK::Suffix, PK)>;
pub fn sub_prefix(&self, p: IK::SubPrefix) -> Prefix<PK, T, (IK::SuperSuffix, PK)>;
@y-pakorn
Copy link
Contributor Author

y-pakorn commented Jun 6, 2022

Sorry, misunderstanding, working as expected now.

@y-pakorn y-pakorn closed this as completed Jun 6, 2022
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

No branches or pull requests

1 participant