These are chat archives for rust-lang/rust

5th
Feb 2019
Arnaud Esteve
@aesteve
Feb 05 21:09
Hi everyone ! I'm back with easier questions for once
Is it possible to collect an iter() into a map I created myself
Kelly Thomas Kline
@kellytk
Feb 05 21:43
For anyone experienced in futures and ideally in actix as well, does the code at https://ghostbin.com/paste/qvh8p look correct? It runs as expected however I'd like to confirm before moving on
David Holroyd
@dholroyd
Feb 05 22:51
I have some types that are just wrappers around &[u8] and which provide accessors to parse the binary data. That's great (and fast) for reading the data format, but seems inconvenient for generation/writing. So I'm considering also having, for each of these types, a struct that can just own a bunch of fields, and then having both the borrowed-slice and plain-owned-struct forms implement a common trait.
So now my question: are there crates already doing this style of thing? Are there established naming conventions for the types implementing each convention?
trait Foo / struct FooOwned / struct FooBorrowed<'a> etc
to maybe make that more concrete, here's an example of the borrowed-slice type that already exists https://github.com/dholroyd/mpeg2ts-reader/blob/master/src/psi/pmt.rs#L38-L90
Ichoran
@Ichoran
Feb 05 23:22
@aesteve - Sure, just implement FromIterator for your map.