Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajjon committed Dec 13, 2023
1 parent cc004c8 commit 813ce09
Show file tree
Hide file tree
Showing 13 changed files with 1,752 additions and 7 deletions.
16 changes: 12 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

resolver = "2"

members = ["identified_vec", "identified_vec_macros"]
members = ["identified_vec", "identified_vec_macros", "tests"]
184 changes: 184 additions & 0 deletions identified_vec/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions identified_vec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "identified_vec"
version = "0.1.4"
edition = "2021"
authors = ["Alexander Cyon <[email protected]>"]
description = "Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type."
license = "MIT"
readme = "README.md"
repository = "https://github.com/Sajjon/identified_vec"
keywords = ["identifiable", "vec", "orderset", "set", "hashset"]
categories = ["data-structures"]

[features]
default = ["id_prim"]
serde = ["dep:serde"]
id_prim = []

[dependencies]
serde = { version = "1.0.193", optional = true }
thiserror = "1.0.50"
18 changes: 18 additions & 0 deletions identified_vec/src/identifiable_trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::fmt::Debug;
use std::hash::Hash;

/// The `Identifiable` trait allows you to use the
/// `IdentifiedVecOf<User> instead of the more verbose
/// `IdentifiedVec<SomeUserID, User>` but also allows you to
/// skip the `id_of_element: fn(&Element) -> ID` closure when
/// initializing a new identified vec.
pub trait Identifiable {
/// The type that your `Element` will use as its globally unique and stable ID,
/// must impl `Hash` since it is used as a key in `IdentifiedVecOf`'s internal
/// `HashMap`. Must impl `Clone` since we need to be able to clone it as a key
type ID: Eq + Hash + Clone + Debug;

/// Return `Element`'s globally unique and stable ID, used to uniquely identify
/// the `Element` in the `IdentifiedVecOf` collection of elements.
fn id(&self) -> Self::ID;
}
Loading

0 comments on commit 813ce09

Please sign in to comment.