Rust's standard libs are still pretty thin on their trait hierarchies, but I'm sure this will change.
Kevin On Sat, Dec 21, 2013 at 1:30 PM, Palmer Cox <[email protected]> wrote: > Are there examples of structs that implement Iterator that also implement > other non-Iterator related traits? Although its possible to do that, I can't > think of a use case for it off the top of my head. An Iterator basically > represents the state of an ongoing computation and once that computation is > completed, the object is mostly uselss. It seems like it would be awkward to > implement other traits for such an object. Maybe I'm not thinking of > something, however. > > -Palmer Cox > > > > On Sat, Dec 21, 2013 at 4:24 PM, Kevin Cantu <[email protected]> wrote: >> >> Iterators are just structs which implement the "Iterator" or a related >> trait, right? >> >> These structs which do can also implement lots of other traits, too: >> no reason to make -Iter special. >> >> >> Kevin >> >> >> >> On Sat, Dec 21, 2013 at 12:50 PM, Palmer Cox <[email protected]> wrote: >> > I'm not a big fan of Hungarian notation either. I'm not sure that having >> > a >> > naming convention for Iterators is Hungarian notation, however. For >> > example, >> > if you are doing Windows programming, you'll see stuff like: >> > >> > DWORD dwFoo = 0; >> > >> > In this case, the "dw" prefix on the variable indicates that we have a >> > DWORD >> > variable. However, the Iterator suffix that I'm proposing here is a >> > suffix >> > on the type names, not the actual variable names. So, if you are writing >> > Rust code, you'd write something like this: >> > >> > let chunks = some_vector.chunks(50); >> > >> > So, the actual variable name doesn't have the Hungarian notation and the >> > types aren't even generally visible since the compiler infers much of >> > that. >> > However, someone reading through the documentation and/or code will see >> > a >> > struct named ChunkIterator and instance know how the struct behaves - as >> > an >> > Iterator. So, I think the suffix serves less to describe the datatype >> > and >> > more to describe class of behavior that the struct implements. >> > >> > Anyway, as I said, I prefer #1. But, I also have done lots of Java >> > programming so I'm probably much more used to verbosity than others. I'm >> > not >> > horribly against some sort of other naming convention, either, of >> > course, >> > but I would like to see some consistency. >> > >> > My main motivation for opening the request was because I created >> > MutChunkIter and then realized that it was named differently than >> > majority >> > of other Iterators. I don't want to be responsible for someone reading >> > through the docs and seeing something thats inconsistent for no good >> > reason! >> > Also, I was reading through some code and happened upon a "Map" and was >> > exceptionally confused about it, until I realized it was iter::Map as >> > opposed to container::Map. I figured I probably wasn't the only person >> > that >> > was going to be confused by something like this. >> > >> > -Palmer Cox >> > >> > >> > >> > >> > >> > On Sat, Dec 21, 2013 at 3:14 PM, Kevin Cantu <[email protected]> wrote: >> >> >> >> IMHO Hungarian notation is for things the type system and tooling >> >> cannot deal with. I'm not sure this is one of them... >> >> >> >> >> >> Kevin >> > >> > > > _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
