How to use dashmap crate in Rust concurrent HashMap

Use the dashmap crate to create a concurrent, thread-safe HashMap in Rust for safe multi-threaded data access.

Add dashmap to your Cargo.toml dependencies and import it to create a thread-safe hash map that allows concurrent reads and writes without external locks.

[dependencies]
dashmap = "6"
use dashmap::DashMap;

fn main() {
    let map: DashMap<String, i32> = DashMap::new();
    map.insert("key", 42);
    if let Some(value) = map.get("key") {
        println!("Value: {}", *value);
    }
}