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

Replace Mapping::insert_return_size with Mapping::insert #1463

Merged
merged 10 commits into from
Nov 8, 2022

Conversation

lean-apple
Copy link
Contributor

@lean-apple lean-apple commented Nov 3, 2022

In the wake of this last change #1224 (comment) where Mapping::insert_return_size was added to make it non-breaking, this method would replace the current insert one for the release 4.0.

More precisely, the method fn Mapping::insert_return_size(key, val) -> Option<u32>; was merged into the method fn Mapping::insert(key, val);

@ascjones
Copy link
Collaborator

ascjones commented Nov 3, 2022

Remove insert and replace insert in mapping and examples

Please give more context in the PR description e.g. "we added a new method to make it non-breaking, now we are doing 4.0 so we can make the breaking change" (it's what I assume the reasoning to be). Also links to relevant PRs are useful #1224

@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2022

Codecov Report

Merging #1463 (d9f4b5e) into master (6b24de9) will increase coverage by 16.98%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           master    #1463       +/-   ##
===========================================
+ Coverage   46.97%   63.96%   +16.98%     
===========================================
  Files         201      201               
  Lines        6210     6210               
===========================================
+ Hits         2917     3972     +1055     
+ Misses       3293     2238     -1055     
Impacted Files Coverage Δ
crates/storage/src/lazy/mapping.rs 70.83% <100.00%> (ø)
crates/engine/src/chain_extension.rs 19.04% <0.00%> (-23.81%) ⬇️
crates/env/src/engine/off_chain/types.rs 0.00% <0.00%> (-21.06%) ⬇️
crates/engine/src/test_api.rs 72.52% <0.00%> (-13.19%) ⬇️
crates/engine/src/ext.rs 55.05% <0.00%> (-12.93%) ⬇️
crates/env/src/engine/off_chain/impls.rs 36.47% <0.00%> (-11.18%) ⬇️
crates/env/src/api.rs 27.69% <0.00%> (-9.24%) ⬇️
crates/env/src/engine/off_chain/test_api.rs 58.82% <0.00%> (-5.89%) ⬇️
crates/ink/ir/src/ir/attrs.rs 78.39% <0.00%> (-0.28%) ⬇️
crates/allocator/src/bump.rs 86.55% <0.00%> (ø)
... and 27 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM, Please add this to the Unreleased section of CHANGELOG.md before merging

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Some nitpicks, but looks good.

Can you update the PR description to include Mapping::insert_return_size in some way? Will make it easier to tell what actually got removed

CHANGELOG.md Outdated
### Changed
- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/paritytech/ink/pull/1467)

### Removed
- Remove `ink_env::random` function ‒ [#1442](https://github.com/paritytech/ink/pull/1442)
- Remove previous insert `Mapping::insert(key, val)` method and replace by `Mapping::insert_return_size(key, val)` behaviour but under the same method name insert - [#1463](https://github.com/paritytech/ink/pull/1463)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you wrap this to ~100 chars?

/// Insert the given `value` to the contract storage.
///
/// Returns the size of the pre-existing value at the specified key if any.
#[inline]
pub fn insert_return_size<Q, R>(&mut self, key: Q, value: &R) -> Option<u32>
pub fn insert<Q, R>(&mut self, key: Q, value: &R) -> Option<u32>
Copy link
Contributor

Choose a reason for hiding this comment

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

In the docs can you also specify the returned size is in bytes?

@ascjones ascjones mentioned this pull request Nov 7, 2022
8 tasks
@HCastano HCastano changed the title Removing previous Insert Replace Mapping::insert_return_size with Mapping::insert Nov 8, 2022
@HCastano HCastano merged commit ec5ed97 into master Nov 8, 2022
@HCastano HCastano deleted the ln-rename-master branch November 8, 2022 11:40
@ascjones ascjones mentioned this pull request Nov 22, 2022
1 task
@ascjones ascjones mentioned this pull request Feb 15, 2023
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

Successfully merging this pull request may close these issues.

4 participants