-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,752 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.