This is a version of generic index types that compiles, but it has still many rough edges. A few examples:
~CustomIndexing trick in traits.rs, which is needed for impl ... for &G, because using just Self causes an (understandable) compilation error. If there is no other way, it should at least get a better name (DelegateIndexing?) and be private?~
~In many cases there is a "VertexRef::data type annotations needed" (VertexRef::data is just one example) error. This is very unergonomic and a solution must be found. This arises from the fact that plain tuples do not hold information about Ix: Indexing.~
~During the implementation, clones were deliberately added anywhere where needed to make code compile. They should be reviewed if some of them can be removed by changing an API (e.g., take something by reference)~ Checked all new clones and I didn't find any good opportunity to avoid a clone (it is either so cheap that it is not worthy to complicate the API or is in testing code).
UseIndex trait in visit::raw is quite an overkill. Maybe it's a necessary implementation detail (we need Ix: Indexing to avoid "Ix is not constrained by trait, Self type, ..." error), but it should not be visible outside of visit::raw.
~Conversions from/to usize for NumIndexType are cumbersome right now as explicit NumIndexType::from_usize must be used instead of simple .into(). This should be improved as well.~
~Use Borrow trait for index arguments, so that both owned indexes and references to indexes can be used in API such as vertex(...) and add_edge(...). This will help ergonomics and aesthetics on the user side in majority of cases, when default index types are used as they are Copy.~
~Make IndexType: Debug~
Following commits should resolve mentioned problems and polish the code in general.
This is a version of generic index types that compiles, but it has still many rough edges. A few examples:
CustomIndexing
trick in traits.rs, which is needed forimpl ... for &G
, because using justSelf
causes an (understandable) compilation error. If there is no other way, it should at least get a better name (DelegateIndexing
?) and be private?~VertexRef::data
is just one example) error. This is very unergonomic and a solution must be found. This arises from the fact that plain tuples do not hold information aboutIx: Indexing
.~UseIndex
trait invisit::raw
is quite an overkill. Maybe it's a necessary implementation detail (we needIx: Indexing
to avoid "Ix is not constrained by trait, Self type, ..." error), but it should not be visible outside ofvisit::raw
.NumIndexType
are cumbersome right now as explicitNumIndexType::from_usize
must be used instead of simple.into()
. This should be improved as well.~vertex(...)
andadd_edge(...)
. This will help ergonomics and aesthetics on the user side in majority of cases, when default index types are used as they areCopy
.~IndexType: Debug
~Following commits should resolve mentioned problems and polish the code in general.