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

Port multisig example to low level data structures #1078

Merged
merged 9 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/storage/src/lazy/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ use ink_primitives::Key;

/// A mapping of key-value pairs directly into contract storage.
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
#[derive(Default)]
pub struct Mapping<K, V> {
offset_key: Key,
_marker: PhantomData<fn() -> (K, V)>,
}

/// We implement this manually because the derived implementation adds trait bounds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What additional trait bounds are added here?

I checked the cargo-expand-ed contracts using both versions and there was no difference between them.

Copy link
Contributor Author

@athei athei Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Default derive requires Default for each type parameter. But for this Mapping we don't need these bounds. In substrate we have a DefaultNoBounds derive for this.

impl<K, V> Default for Mapping<K, V> {
fn default() -> Self {
Self {
offset_key: Default::default(),
_marker: Default::default(),
}
}
}

impl<K, V> core::fmt::Debug for Mapping<K, V> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mapping")
Expand Down
Loading