Skip to content

Commit

Permalink
storage-plus: Rename CwIntKey trait to IntKey
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb authored and Mauro Lacy committed Aug 16, 2022
1 parent f850218 commit 23136bb
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/storage-plus/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand::Rng;
use std::mem;
use std::time::Duration;

use cw_storage_plus::CwIntKey;
use cw_storage_plus::IntKey;

fn bench_signed_int_key(c: &mut Criterion) {
let mut group = c.benchmark_group("Signed int keys");
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::TryInto;

use cosmwasm_std::{Addr, StdError, StdResult};

use crate::int_key::CwIntKey;
use crate::int_key::IntKey;

pub trait KeyDeserialize {
type Output: Sized;
Expand Down
7 changes: 3 additions & 4 deletions packages/storage-plus/src/int_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::mem;
/// but "sign-flipped" (xored msb) big-endian bytes for signed ints.
///
/// So that the representation of signed integers is in the right lexicographical order.
// TODO: Rename to `IntKey` after deprecating current `IntKey` (https://github.com/CosmWasm/cw-plus/issues/570)
pub trait CwIntKey: Sized + Copy {
pub trait IntKey: Sized + Copy {
type Buf: AsRef<[u8]> + AsMut<[u8]> + Into<Vec<u8>> + Default;

fn to_cw_bytes(&self) -> Self::Buf;
Expand All @@ -14,7 +13,7 @@ pub trait CwIntKey: Sized + Copy {

macro_rules! cw_uint_keys {
(for $($t:ty),+) => {
$(impl CwIntKey for $t {
$(impl IntKey for $t {
type Buf = [u8; mem::size_of::<$t>()];

#[inline]
Expand All @@ -34,7 +33,7 @@ cw_uint_keys!(for u8, u16, u32, u64, u128);

macro_rules! cw_int_keys {
(for $($t:ty, $ut:ty),+) => {
$(impl CwIntKey for $t {
$(impl IntKey for $t {
type Buf = [u8; mem::size_of::<$t>()];

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cosmwasm_std::Addr;

use crate::de::KeyDeserialize;
use crate::helpers::namespaces_with_key;
use crate::int_key::CwIntKey;
use crate::int_key::IntKey;

#[derive(Debug)]
pub enum Key<'a> {
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use indexes::Index;
pub use indexes::MultiIndex;
#[cfg(feature = "iterator")]
pub use indexes::UniqueIndex;
pub use int_key::CwIntKey;
pub use int_key::IntKey;
pub use item::Item;
pub use keys::{Key, Prefixer, PrimaryKey};
pub use map::Map;
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-plus/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ mod test {
#[cfg(feature = "iterator")]
use crate::bound::Bounder;

use crate::int_key::CwIntKey;
use crate::int_key::IntKey;

#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
struct Data {
Expand Down

0 comments on commit 23136bb

Please sign in to comment.