Giter Club home page Giter Club logo

Comments (8)

Robbepop avatar Robbepop commented on August 25, 2024

This commit adds std::ops::{Add, AddAssign} implementations for Key for u32 and u64.

  • Signed versions will follow.
  • Concerns about adding another std::ops::Sub and std::ops::SubAssign implementation.
  • Also we could add something similar to a ptrdiff with std::ops::Sub<Key> for Key impl. However, what return type should it have?

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Commits 8880390 and 10e5f15 remove Key::with_chunk_offset and Key::with_offset in favor of the new core::ops::{Add, AddAssign} implementations.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Commit 42c490b marks Env::load as unsafe fn since it compares itself with a pointer deref in Rust which is also known as being an unsafe operation.

Changes to Env::store and Env::clear will follow with the same reasoning.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Commit bb2e8ee marks the other Env::{store, clear} fns as unsafe as the previous commit.

This shall guide users of pdsl_core to use the safer cell, chunk and collections abstractions.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Commit 89b0be5 adds core::ops::Sub impl for Key and the KeyDiff type.
Look at commit 4509914 on how to use this new interface.

Currently missing are some unit tests for KeyDiff.

Edit: Commit b91fb4a adds simple unit tests for KeyDiff.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Missing pieces:

  • impl core::ops::Sub<{u32, u64, u128}> for Key
  • impl core::ops::Add<u128> for Key
  • impl core::ops::Add<{i32, i64, i128}> for Key. Note that this hasn't been made yet since the unsigned variants can be implemented a bit more efficiently. This might not be transparent to users so could lead to a slight performance degradation when using signed instead of unsigned after implementing this. Besides that these trait implementations are for convenience. This requires a byte_utils::sign_extend procedure to sign extend the i32, i64 or i128 to the 32 byte of a key in order to subtract or add from or to it.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

Besides other things this commit adds core::ops::{Sub, SubAssign} implementations for Key.

Also during implementation we found out that core::ops::{Add,AddAssign,Sub,SubAssign} implementations for RHS = {i32,i64,i128} do not make sense and are semantically difficult to articulate on Key instances so it is better to leave them away and stay with the unsigned variants that have a semantically clear usage story.

So after removing this work item what is missing is implementations of core::ops::{Add,AddAssign,Sub,SubAssign} ofu128 for Key and also a conversion impl from KeyDiff to u128.

from ink.

Robbepop avatar Robbepop commented on August 25, 2024

The remaining parts have been implemented in 966d29d, bc711cb and 09b7bbd.

from ink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.