-
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.
Merge pull request #9 from Sajjon/is_id_vec
Add `IsIdentifiableVecOfVia` trait and `newtype_identified_vec` macro
- Loading branch information
Showing
21 changed files
with
1,324 additions
and
445 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,5 @@ | ||
[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"] | ||
[workspace] | ||
|
||
[features] | ||
serde = ["dep:serde"] | ||
id_prim = [] | ||
resolver = "2" | ||
|
||
[dependencies] | ||
serde = { version = "1.0.193", optional = true } | ||
thiserror = "1.0.50" | ||
|
||
[dev-dependencies] | ||
identified_vec = { path = ".", features = ["id_prim", "serde"] } | ||
serde = "1.0.193" | ||
serde_json = "1.0.108" | ||
rand = "0.8.5" | ||
maplit = "1.0.2" | ||
members = ["identified_vec", "identified_vec_macros", "tests"] |
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.5" | ||
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,10 @@ | ||
/// Representation of a choice in a conflict resolution | ||
/// where two elements with the same Self::ID exists, if `ChooseFirst`, | ||
/// is specified the first/current/existing value will be used, but | ||
/// if `ChooseLast` is specified then the new/last will be replace | ||
/// the first/current/existing. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
pub enum ConflictResolutionChoice { | ||
ChooseFirst, | ||
ChooseLast, | ||
} |
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
use crate::is_identifiable_vec::IsIdentifiableVec; | ||
use crate::vec::IdentifiedVec; | ||
use std::fmt::Debug; | ||
use std::hash::Hash; | ||
|
||
/// An owning iterator over the items of an `IdentifiedVec`. | ||
pub struct IdentifiedVecIntoIterator<I, E> | ||
where | ||
I: Eq + Hash + Clone + Debug, | ||
{ | ||
identified_vec: IdentifiedVec<I, E>, | ||
} | ||
|
||
impl<I, E> IdentifiedVecIntoIterator<I, E> | ||
where | ||
I: Eq + Hash + Clone + Debug, | ||
{ | ||
pub fn new(identified_vec: IdentifiedVec<I, E>) -> Self { | ||
Self { identified_vec } | ||
} | ||
} | ||
|
||
impl<I, E> Iterator for IdentifiedVecIntoIterator<I, E> | ||
where | ||
I: Eq + Hash + Clone + Debug, | ||
{ | ||
type Item = E; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
if self.identified_vec.len() == 0 { | ||
return None; | ||
} | ||
let result = self.identified_vec.remove_at(0); | ||
Some(result) | ||
} | ||
} |
Oops, something went wrong.