Skip to content

Commit c8fc764

Browse files
committed
Initial implementation for interned.
1 parent 76dc8fa commit c8fc764

File tree

12 files changed

+1903
-1044
lines changed

12 files changed

+1903
-1044
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/target
2-
Cargo.lock
2+
/Cargo.lock

Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
[package]
22
name = "repository"
3-
version = "0.0.2"
3+
version = "0.1.0"
44
authors = ["Charles Lew <[email protected]>"]
55
license = "MIT OR Apache-2.0"
6-
edition = "2018"
6+
edition = "2021"
77
description = "A repository for all kinds of entities."
88
repository = "https://github.com/crlf0710/repository-rs"
99

10+
[lib]
11+
name = "repo"
12+
13+
[features]
14+
keyed = []
15+
1016
[dependencies]
11-
hashbrown = {version = "0.9.0", features = ['raw']}
12-
thiserror = "1.0.20"
17+
repository-macros = {version = "0.1.0", path = "repository-macros"}
18+
elsa = "1.7.0"
19+
indexmap = "1.9.1"
20+
21+
[workspace]
22+
members = ["repository-macros"]

README.md

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,3 @@
11
## Repository: A repository for all kinds of entities.
22

3-
`Repository` provides storage for multiple data types, it provides
4-
its own kind of index handle called `EntityId` and its own kind of typed
5-
handle called `EntityPtr<T>`. With these handles it allows the values
6-
resident in the same `Repository` to reference each other easily.
7-
8-
The data behind the `EntityPtr<T>` handle can be accessed when you have
9-
a corresponding reference to the whole repository.
10-
11-
The data behind the `EntityId` handle can be accessed when you know its
12-
type and have a corresponding reference to the whole repository.
13-
14-
### Usage example:
15-
```rust
16-
// create a repository.
17-
let mut repo = Repo::new();
18-
19-
// insert and retrieve a pointer handle.
20-
let a = repo.insert(42i32);
21-
assert_eq!(42i32, *a.get_ref(&repo).unwrap());
22-
23-
// insert and retrieve a index handle.
24-
let b = repo.insert_for_id(42i32);
25-
26-
// downcast from index handle to pointer handle.
27-
let b_ptr = b.cast_ptr::<i32>(&repo).unwrap();
28-
assert_eq!(42i32, *b_ptr.get_ref(&repo).unwrap());
29-
30-
// downcasting fails when type is incorrect.
31-
let b_wrong_ptr = b.cast_ptr::<u32>(&repo);
32-
assert_eq!(None, b_wrong_ptr);
33-
```
34-
35-
#### License
36-
37-
<sup>
38-
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
39-
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
40-
</sup>
41-
42-
<br>
43-
44-
<sub>
45-
Unless you explicitly state otherwise, any contribution intentionally submitted
46-
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
47-
be dual licensed as above, without any additional terms or conditions.
48-
</sub>
3+
Heavily inspired by `salsa`, `superstruct` and various other crates.

repository-macros/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "repository-macros"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
proc-macro = true
8+
9+
[dependencies]
10+
heck = "0.4.0"
11+
proc-macro2 = "1.0.44"
12+
quote = "1.0.21"
13+
syn = {version = "1.0.100", features = ["full", "extra-traits"]}

0 commit comments

Comments
 (0)