Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: indexmap-rs/ordermap
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.5.5
Choose a base ref
...
head repository: indexmap-rs/ordermap
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.5.6
Choose a head ref
  • 9 commits
  • 6 files changed
  • 3 contributors

Commits on Jan 21, 2025

  1. Upgrade dev-dependency itertools to 0.14

    (cherry picked from commit b135634)
    cuviper committed Jan 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    OlegDokuka Oleh Dokuka
    Copy the full SHA
    853a6a7 View commit details
  2. Merge pull request #7 from cuviper/itertools-0.14

    Upgrade dev-dependency `itertools` to 0.14
    cuviper authored Jan 21, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    OlegDokuka Oleh Dokuka
    Copy the full SHA
    74d8815 View commit details

Commits on Jan 22, 2025

  1. ci: use cargo-nextest with miri

    cuviper committed Jan 22, 2025
    Copy the full SHA
    4ddbcbe View commit details
  2. Merge pull request #8 from cuviper/miri-nextest

    ci: use cargo-nextest with miri
    cuviper authored Jan 22, 2025
    Copy the full SHA
    6f32254 View commit details
  3. Rename master to main

    cuviper committed Jan 22, 2025
    Copy the full SHA
    055e45e View commit details

Commits on Mar 10, 2025

  1. Upgrade dev-dependency rand to 0.9

    (cherry picked from commit b8bdead)
    waywardmonkeys authored and cuviper committed Mar 10, 2025
    Copy the full SHA
    5b325a4 View commit details
  2. feat: add ordermap_with_default and orderset_with_default macros

    (cherry picked from commit 5fd8971)
    
    Ported from indexmap to ordermap.
    
    Co-authored-by: Josh Stone <cuviper@gmail.com>
    iajoiner and cuviper committed Mar 10, 2025
    Copy the full SHA
    c64da33 View commit details
  3. Release 0.5.6

    cuviper committed Mar 10, 2025
    Copy the full SHA
    5a091d8 View commit details
  4. Merge pull request #9 from cuviper/release-0.5.6

    Release 0.5.6
    cuviper authored Mar 10, 2025
    Copy the full SHA
    266d74c View commit details
Showing with 97 additions and 12 deletions.
  1. +8 −4 .github/workflows/ci.yml
  2. +5 −5 Cargo.toml
  3. +2 −2 README.md
  4. +6 −0 RELEASES.md
  5. +2 −1 src/lib.rs
  6. +74 −0 src/macros.rs
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
merge_group:

name: CI
@@ -111,8 +111,12 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- run: cargo miri test
components: miri, rust-src
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- run: cargo miri nextest run
- run: cargo miri test --doc

minimal-versions:
name: Check MSRV and minimal-versions
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ordermap"
edition = "2021"
version = "0.5.5"
version = "0.5.6"
documentation = "https://docs.rs/ordermap/"
repository = "https://github.com/indexmap-rs/ordermap"
license = "Apache-2.0 OR MIT"
@@ -14,7 +14,7 @@ rust-version = "1.63"
bench = false

[dependencies]
indexmap = { version = "2.7.1", default-features = false }
indexmap = { version = "2.8.0", default-features = false }

arbitrary = { version = "1.0", optional = true, default-features = false }
quickcheck = { version = "1.0", optional = true, default-features = false }
@@ -23,8 +23,8 @@ borsh = { version = "1.2", optional = true, default-features = false }
rayon = { version = "1.9", optional = true }

[dev-dependencies]
itertools = "0.13"
rand = {version = "0.8", features = ["small_rng"] }
itertools = "0.14"
rand = {version = "0.9", features = ["small_rng"] }
quickcheck = { version = "1.0", default-features = false }
fnv = "1.0"
lazy_static = "1.3"
@@ -44,7 +44,7 @@ borsh = ["dep:borsh", "indexmap/borsh"]
debug = true

[package.metadata.release]
allow-branch = ["master"]
allow-branch = ["main"]
sign-tag = true
tag-name = "{{version}}"

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ordermap

[![build status](https://github.com/indexmap-rs/ordermap/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/indexmap-rs/ordermap/actions)
[![build status](https://github.com/indexmap-rs/ordermap/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/indexmap-rs/ordermap/actions)
[![crates.io](https://img.shields.io/crates/v/ordermap.svg)](https://crates.io/crates/ordermap)
[![docs](https://docs.rs/ordermap/badge.svg)](https://docs.rs/ordermap)
[![rustc](https://img.shields.io/badge/rust-1.63%2B-orange.svg)](https://img.shields.io/badge/rust-1.63%2B-orange.svg)
@@ -60,4 +60,4 @@ which is roughly:

# Recent Changes

See [RELEASES.md](https://github.com/indexmap-rs/ordermap/blob/master/RELEASES.md).
See [RELEASES.md](https://github.com/indexmap-rs/ordermap/blob/main/RELEASES.md).
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Releases

## 0.5.6 (2025-03-10)

- Added `ordermap_with_default!` and `orderset_with_default!` to be used with
alternative hashers, especially when using the crate without `std`.
- Updated the `indexmap` dependency to version 2.8.0.

## 0.5.5 (2025-01-19)

- Added `#[track_caller]` to functions that may panic.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,8 @@
//! [`with_capacity_and_hasher`][OrderMap::with_capacity_and_hasher] instead.
//! A no-std compatible hasher will be needed as well, for example
//! from the crate `twox-hash`.
//! - Macros [`ordermap!`] and [`orderset!`] are unavailable without `std`.
//! - Macros [`ordermap!`] and [`orderset!`] are unavailable without `std`. Use
//! the macros [`ordermap_with_default!`] and [`orderset_with_default!`] instead.
#![cfg_attr(docsrs, feature(doc_cfg))]

74 changes: 74 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
/// Create an [`OrderMap`][crate::OrderMap] from a list of key-value pairs
/// and a `BuildHasherDefault`-wrapped custom hasher.
///
/// ## Example
///
/// ```
/// use ordermap::ordermap_with_default;
/// use fnv::FnvHasher;
///
/// let map = ordermap_with_default!{
/// FnvHasher;
/// "a" => 1,
/// "b" => 2,
/// };
/// assert_eq!(map["a"], 1);
/// assert_eq!(map["b"], 2);
/// assert_eq!(map.get("c"), None);
///
/// // "a" is the first key
/// assert_eq!(map.keys().next(), Some(&"a"));
/// ```
#[macro_export]
macro_rules! ordermap_with_default {
($H:ty; $($key:expr => $value:expr,)+) => { $crate::ordermap_with_default!($H; $($key => $value),+) };
($H:ty; $($key:expr => $value:expr),*) => {{
let builder = ::core::hash::BuildHasherDefault::<$H>::default();
const CAP: usize = <[()]>::len(&[$({ stringify!($key); }),*]);
#[allow(unused_mut)]
// Specify your custom `H` (must implement Default + Hasher) as the hasher:
let mut map = $crate::OrderMap::with_capacity_and_hasher(CAP, builder);
$(
map.insert($key, $value);
)*
map
}};
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[macro_export]
@@ -35,6 +72,43 @@ macro_rules! ordermap {
};
}

/// Create an [`OrderSet`][crate::OrderSet] from a list of values
/// and a `BuildHasherDefault`-wrapped custom hasher.
///
/// ## Example
///
/// ```
/// use ordermap::orderset_with_default;
/// use fnv::FnvHasher;
///
/// let set = orderset_with_default!{
/// FnvHasher;
/// "a",
/// "b",
/// };
/// assert!(set.contains("a"));
/// assert!(set.contains("b"));
/// assert!(!set.contains("c"));
///
/// // "a" is the first value
/// assert_eq!(set.iter().next(), Some(&"a"));
/// ```
#[macro_export]
macro_rules! orderset_with_default {
($H:ty; $($value:expr,)+) => { $crate::orderset_with_default!($H; $($value),+) };
($H:ty; $($value:expr),*) => {{
let builder = ::core::hash::BuildHasherDefault::<$H>::default();
const CAP: usize = <[()]>::len(&[$({ stringify!($value); }),*]);
#[allow(unused_mut)]
// Specify your custom `H` (must implement Default + Hash) as the hasher:
let mut set = $crate::OrderSet::with_capacity_and_hasher(CAP, builder);
$(
set.insert($value);
)*
set
}};
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[macro_export]