Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 25, 2024
1 parent 8aaef37 commit 2dd2218
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions src/pages/storey/containers/map.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ assert_eq!(access.entry("alice").get().unwrap(), Some(Uint128::new(1000)));
the keys in the underlying storage backend.
- _line 8:_ The [`access`] method returns a [`MapAccess`] entity, which allows manipulating the map.
- _line 10:_ Here we try to access the balance of `alice`. Since she doesn't have one yet, it
returns `None`. The [`entry`] method returns an [`ItemAccess`] entity, which allows manipulating the
item stored under the key `alice`.
returns `None`. The [`entry`] method returns an [`ItemAccess`] entity, which allows manipulating
the item stored under the key `alice`.
- _line 12:_ Here we set Alice's balance to `1000`.
- _line 14:_ We check that the balance is now `1000`.

#### Iterating over the balances

Iterating over the balances is pretty straightforward. The [`keys`] method returns an iterator over
the keys, the [`values`] method returns an iterator over the values, and the [`pairs`] method returns an
iterator over both.
the keys, the [`values`] method returns an iterator over the values, and the [`pairs`] method
returns an iterator over both.

```rust template="storage" showLineNumbers {4, 17, 19}
use cw_storey::containers::{Item, Map};
Expand Down Expand Up @@ -121,8 +121,8 @@ assert_eq!(
Here we used the [`bounded_pairs`] method to iterate over some key-value pairs. Other bounded
methods are also available: [`bounded_keys`] and [`bounded_values`].

The bounds are provided as arguments to the methods. Currently, the bounds are inclusive on the lower
bound and exclusive on the upper bound. In a future release (soon!) this will be configurable.
The bounds are provided as arguments to the methods. Currently, the bounds are inclusive on the
lower bound and exclusive on the upper bound. In a future release (soon!) this will be configurable.

### Keeping balances with composition

Expand Down Expand Up @@ -151,8 +151,8 @@ This example is similar to the previous one, but this time we have an extra leve
First of all, our type is `Map<String, Map<String, Item<Uint128>>>`. The outer map maps user
addresses to inner maps. The inner map maps token denominations to actual balances.

When we access the stuff, the first [`entry`]/[`entry_mut`] call accesses a record in the outer map, and
the second one accesses a record in the inner map.
When we access the stuff, the first [`entry`]/[`entry_mut`] call accesses a record in the outer map,
and the second one accesses a record in the inner map.

<Callout>
In [`cw-storage-plus`], you can achieve the same
Expand Down Expand Up @@ -196,7 +196,8 @@ assert_eq!(
);
```

Here we iterated twice, but each time we got a different view of the data. Each iteration was at a different level.
Here we iterated twice, but each time we got a different view of the data. Each iteration was at a
different level.

- _line 18:_ We call `pairs` on the outer map, which gives us all the entries.
- _line 27:_ We call `pairs` on the inner map under the key `alice`, which gives us all of Alice's
Expand All @@ -215,20 +216,26 @@ Bounded or sensibly ordered iteration is not possible when both of the following
- The key is dynamically sized (e.g. `String`, `Vec<u8>`, etc.).
- The value type is a collection (`Map`, `Column`, etc.) rather than something like `Item`.

This is why, in the example above, bounded iteration (and a sensible order) is only possible for
the inner map.
This is why, in the example above, bounded iteration (and a sensible order) is only possible for the
inner map.

</Callout>

[`cw-storage-plus`]: /cw-storage-plus/containers/map
[`bounded_pairs`]: https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_pairs
[`bounded_keys`]: https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_keys
[`bounded_values`]: https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_values
[`bounded_pairs`]:
https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_pairs
[`bounded_keys`]:
https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_keys
[`bounded_values`]:
https://docs.rs/storey/latest/storey/containers/trait.BoundedIterableAccessor.html#method.bounded_values
[`access`]: https://docs.rs/storey/latest/storey/containers/map/struct.Map.html#method.access
[`entry`]: https://docs.rs/storey/latest/storey/containers/map/struct.MapAccess.html#method.entry
[`entry_mut`]: https://docs.rs/storey/latest/storey/containers/map/struct.MapAccess.html#method.entry_mut
[`entry_mut`]:
https://docs.rs/storey/latest/storey/containers/map/struct.MapAccess.html#method.entry_mut
[`keys`]: https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html#method.keys
[`values`]: https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html#method.values
[`values`]:
https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html#method.values
[`pairs`]: https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html#method.pairs
[`ItemAccess`]: https://docs.rs/storey/latest/storey/containers/struct.ItemAccess.html
[`MapAccess`]: https://docs.rs/storey/latest/storey/containers/map/struct.MapAccess.html
[`IterableAccessor`]: https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html
[`IterableAccessor`]: https://docs.rs/storey/latest/storey/containers/trait.IterableAccessor.html

0 comments on commit 2dd2218

Please sign in to comment.