1 个稳定版本

使用旧的 Rust 2015

1.0.0 2022年9月3日

#1933数据库接口

Download history • Rust 包仓库 36550/week @ 2024-03-14 • Rust 包仓库 35043/week @ 2024-03-21 • Rust 包仓库 33550/week @ 2024-03-28 • Rust 包仓库 34505/week @ 2024-04-04 • Rust 包仓库 36255/week @ 2024-04-11 • Rust 包仓库 39633/week @ 2024-04-18 • Rust 包仓库 40007/week @ 2024-04-25 • Rust 包仓库 40468/week @ 2024-05-02 • Rust 包仓库 41622/week @ 2024-05-09 • Rust 包仓库 38781/week @ 2024-05-16 • Rust 包仓库 40601/week @ 2024-05-23 • Rust 包仓库 42679/week @ 2024-05-30 • Rust 包仓库 49193/week @ 2024-06-06 • Rust 包仓库 41525/week @ 2024-06-13 • Rust 包仓库 36794/week @ 2024-06-20 • Rust 包仓库 35852/week @ 2024-06-27 • Rust 包仓库

171,819 每月下载量
用于 6 个 Crates (3 直接)

MIT 许可协议

19KB
397

typemap-ors CI

以类型为键的存储,包含不同类型的值。

文档

它提供了类似于 AnyMap 的功能,但更灵活,因为它允许键值对而不是强制键和值具有相同的类型。

通过 Key 特性定义键值关联,该特性使用关联类型参数和特性一致性规则来强制执行 TypeMap 的不变性。

示例

extern crate typemap;
use typemap::{TypeMap, Key};

struct KeyType;

#[derive(Debug, PartialEq)]
struct Value(i32);

impl Key for KeyType { type Value = Value; }

#[test] fn test_pairing() {
    let mut map = TypeMap::new();
    map.insert::<KeyType>(Value(42));
    assert_eq!(*map.get::<KeyType>().unwrap(), Value(42));
}

lib.rs:

一种基于类型的键值存储,每个键允许一个值类型。

依赖项

~16KB