Comments (3)
I experimented this implementation but here are the problems.
If the new
method is changed to
pub fn new(v: I) -> Result<Self>
where
I: IntoIterator<Item = T>;
Then the implementation will call .into_iter()
then .collect()
to collect as a Vec
. If the input parameter is already a Vec
, this is an aberration to iterate over it in order to collect it again as a Vec
.
Another solution would be to provide a From<IntoIterator<Item = T>>
implementation. But this one causes also a problem. Below is a possible implementation.
impl<T: Id<T>, I: IntoIterator<Item = T>> From<I> for CollectionWithId<T> {
fn from(iterator: I) -> Self {
// This cannot fail since there will be a unique identifier in the
// collection hence no identifier's collision.
CollectionWithId::new(iterator.into_iter().collect()).unwrap()
}
}
But it does not compile since it creates a conflicting implementation.
error[E0119]: conflicting implementations of trait `std::convert::From<collection::CollectionWithId<_>>` for type `collection::CollectionWithId<_>`:
--> collection/src/collection.rs:405:1
|
405 | impl<T: Id<T>, I: IntoIterator<Item = T>> From<I> for CollectionWithId<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::convert::From<T> for T;
error: aborting due to previous error
Anyone has some ideas about that?
from transit_model.
Note that there is a FromIterator
trait that could be implemented but this option has already been explored and rejected in #291.
from transit_model.
Therefore, let's close this issue (especially since this functionality has moved to its own repository now hove-io/typed_index_collections
).
from transit_model.
Related Issues (20)
- gtfs2netexfr installation issue HOT 11
- merge-ntfs HOT 2
- gtfs2ntfs : new way to generate prefixes ? HOT 4
- better object duplicate error HOT 4
- Error reading "./ntfs/feed_infos.txt" HOT 3
- Add more flexibility to read inputs HOT 1
- [tech] Easier hello world HOT 8
- Allow reading GTFS csv files with a flexible option for columns number HOT 2
- Do gtfs2netexfr handle the pathways and levels GTFS extensions ? HOT 1
- FR: prefixes dans les id HOT 4
- Coordonnées WGS HOT 5
- SiteConnection id not unique HOT 2
- [tech] Improve ignored doc-tests
- [gtfs2netexfr] Help needed to pinpoint cause of "unused lines" pruning HOT 3
- transit_model fails to open zipped file. HOT 8
- TransXChange format HOT 1
- ODT : incorrect behavior ? HOT 10
- Problem with cargo install --path gtfs2netexfr HOT 4
- gtfs2netexfr : wrong StopPlaceType for bus HOT 5
- Dependency minidom 0.12 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transit_model.