Skip to content

Commit

Permalink
upgrade to 0.1.2 (#1) (#2)
Browse files Browse the repository at this point in the history
1. support by value and by ref method
  • Loading branch information
SF-Zhou authored Dec 25, 2024
1 parent aa4697a commit 3a685b8
Show file tree
Hide file tree
Showing 5 changed files with 490 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lockmap"
version = "0.1.1"
version = "0.1.2"
edition = "2021"

authors = ["SF-Zhou <sfzhou.scut@gmail.com>"]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ A high-performance, thread-safe HashMap implementation for Rust that provides fi
use lockmap::LockMap;

// Create a new lock map
let map = LockMap::new();
let map = LockMap::<String, String>::new();

// Set a value
map.set("key", "value");
map.set_by_ref("key", "value".into());

// Get a value
assert_eq!(map.get("key"), Some("value"));
assert_eq!(map.get_by_ref("key"), Some("value".into()));

// Use entry API for exclusive access
{
let entry = map.entry("key");
*entry.value = Some("new value");
let entry = map.entry_by_ref("key");
*entry.value = Some("new value".into());
}

// Remove a value
map.remove("key");
map.remove_by_ref("key");
```
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
//! let map = LockMap::<String, u32>::new();
//!
//! // Basic operations
//! map.set("key1", 42);
//! assert_eq!(map.get("key1"), Some(42));
//! map.set("key1".into(), 42);
//! assert_eq!(map.get("key1".into()), Some(42));
//!
//! // Entry API for exclusive access
//! {
//! let entry = map.entry("key2");
//! let entry = map.entry("key2".into());
//! entry.value.replace(123);
//! }
//! ```
#[doc = include_str!("../README.md")]
mod lockmap;
mod shards_map;
mod waiter;
Expand Down
Loading

0 comments on commit 3a685b8

Please sign in to comment.