-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Same as #123 but without generational_indexes. I think the indexes are really great for performance since: * all structures are then `Vector` (great random access and cache friendly iterations) * the ids are short (integer vs string) I don't think we need those performance in this crate though. Having only typed index (a think wrapper over the real gtfs identifier) would be more convenient I think. It would: * ease debug (easy to print the gtfs identifier, instead of having a meaningless integer) * ease serialisation (same, we can serialize the string right away) * be a more more close to the gtfs representation This is still *very* early WIP, I'm not convinced at all by the ergonomics, I'd like to keep the property of the Index in #123 that the `Id` have at least existed at one point (even if I don't plan to ensure this if an object is deleted).
- Loading branch information
1 parent
90db386
commit 730b882
Showing
5 changed files
with
90 additions
and
61 deletions.
There are no files selected for viewing
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
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
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,31 @@ | ||
use core::marker::PhantomData; | ||
#[derive(Derivative)] | ||
#[derive(Serialize, Deserialize)] | ||
#[derivative(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)] | ||
pub struct Id<T> { | ||
id: String, | ||
#[serde(skip)] | ||
#[derivative(Debug(bound = ""))] | ||
#[derivative(Debug = "ignore")] | ||
#[derivative(Clone(bound = ""))] | ||
#[derivative(Eq(bound = ""))] | ||
#[derivative(PartialEq(bound = ""))] | ||
#[derivative(Hash(bound = ""))] | ||
_phantom: PhantomData<T>, | ||
} | ||
|
||
impl<T> Id<T> { | ||
pub fn must_exists(s: String) -> Id<T> { | ||
Id { | ||
id: s, | ||
_phantom: PhantomData, | ||
} | ||
} | ||
} | ||
|
||
impl<T> std::ops::Deref for Id<T> { | ||
type Target = str; | ||
fn deref(&self) -> &str { | ||
&self.id | ||
} | ||
} |
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
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