diff --git a/.circleci/config.yml b/.circleci/config.yml index 75ba021d7..4602c28b6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -660,11 +660,11 @@ jobs: name: Run unit tests (no iterator) command: cargo test --locked --no-default-features - run: - name: Build library for native target (with iterator) - command: cargo build --locked + name: Build library for native target (with iterator and macro) + command: cargo build --locked --all-features - run: - name: Run unit tests (with iterator) - command: cargo test --locked + name: Run unit tests (with iterator and macro) + command: cargo test --locked --all-features - save_cache: paths: - /usr/local/cargo/registry diff --git a/Cargo.lock b/Cargo.lock index 93c0d63f0..0f790ab7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -433,7 +433,6 @@ name = "cw-storage-macro" version = "0.15.1" dependencies = [ "cosmwasm-std", - "cw-storage-plus", "serde", "syn", ] diff --git a/packages/storage-macro/Cargo.toml b/packages/storage-macro/Cargo.toml index 48cd9537d..ce5740516 100644 --- a/packages/storage-macro/Cargo.toml +++ b/packages/storage-macro/Cargo.toml @@ -16,6 +16,5 @@ proc-macro = true syn = { version = "1.0.96", features = ["full"] } [dev-dependencies] -cw-storage-plus = { version = "<=0.15.1, >=0.14.0", path = "../storage-plus" } cosmwasm-std = { version = "1.1.0", default-features = false } serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 7f453420a..b170ff34b 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -8,6 +8,9 @@ license = "Apache-2.0" repository = "https://github.com/CosmWasm/cw-plus" homepage = "https://cosmwasm.com" +[package.metadata.docs.rs] +all-features = true # include macro feature when building docs + [features] default = ["iterator"] iterator = ["cosmwasm-std/iterator"] @@ -24,7 +27,7 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } cw-storage-macro = { version = "0.15.1", optional = true, path = "../storage-macro" } [dev-dependencies] -criterion = { version = "0.3", features = [ "html_reports" ] } +criterion = { version = "0.3", features = ["html_reports"] } rand = "0.8" [[bench]] diff --git a/packages/storage-plus/src/lib.rs b/packages/storage-plus/src/lib.rs index 014834bf8..00208b499 100644 --- a/packages/storage-plus/src/lib.rs +++ b/packages/storage-plus/src/lib.rs @@ -42,9 +42,32 @@ pub use prefix::{range_with_prefix, Prefix}; #[cfg(feature = "iterator")] pub use snapshot::{SnapshotItem, SnapshotMap, Strategy}; +// cw_storage_macro reexports #[cfg(all(feature = "iterator", feature = "macro"))] #[macro_use] extern crate cw_storage_macro; #[cfg(all(feature = "iterator", feature = "macro"))] -#[doc(hidden)] -pub use cw_storage_macro::*; +/// Auto generate an `IndexList` impl for your indexes struct. +/// +/// # Example +/// +/// ```rust +/// use cosmwasm_std::Addr; +/// use cw_storage_plus::{MultiIndex, UniqueIndex, index_list}; +/// use serde::{Serialize, Deserialize}; +/// +/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +/// struct TestStruct { +/// id: u64, +/// id2: u32, +/// addr: Addr, +/// } +/// +/// #[index_list(TestStruct)] // <- Add this line right here. +/// struct TestIndexes<'a> { +/// id: MultiIndex<'a, u32, TestStruct, u64>, +/// addr: UniqueIndex<'a, Addr, TestStruct>, +/// } +/// ``` +/// +pub use cw_storage_macro::index_list; diff --git a/packages/storage-macro/tests/index_list.rs b/packages/storage-plus/tests/index_list.rs similarity index 97% rename from packages/storage-macro/tests/index_list.rs rename to packages/storage-plus/tests/index_list.rs index 224b20551..db0d2b843 100644 --- a/packages/storage-macro/tests/index_list.rs +++ b/packages/storage-plus/tests/index_list.rs @@ -1,4 +1,4 @@ -#[cfg(test)] +#[cfg(all(test, feature = "iterator", feature = "macro"))] mod test { use cosmwasm_std::{testing::MockStorage, Addr}; use cw_storage_macro::index_list;