Skip to content

Commit

Permalink
Explain concatenation in more details
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan770 committed Jan 26, 2023
1 parent b54a218 commit 4f807db
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/complex-storage-structures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ struct MyStruct {
```

On the other hand, you can manually set storage key offset for your struct. This offset will apply to every non-packed field in a struct:

```rust
#[ink::storage_item]
struct MyStruct<KEY: StorageKey> {
Expand All @@ -238,6 +239,9 @@ struct MyStruct<KEY: StorageKey> {
}
```

When your struct has a `KEY` generic existing, the `#[ink::storage_item]` macro will automatically set
the `ParentKey` generic value to `KEY`, basically concatenating two values together.

The reason to do it in such way is that you can use the same type in different places and set different storage keys for them.

For example if you want to use it in contract, you can do it like this:
Expand Down

0 comments on commit 4f807db

Please sign in to comment.