I believe you will be able to say `fn elements(&self) -> impl Iterator<K> {
... }` and the proper type would be inferred -- but must implement
`Iterator<K>`.


On Wed, May 28, 2014 at 10:25 AM, schmee <notifications@github.com> wrote:

> In src/libcollections/counted_set.rs:
>
> > +    }
> > +
> > +    /// Returns the `n` most common elements and their counts in descending
> > +    /// order.
> > +    pub fn most_common(&self, n: uint) -> Vec<(K, uint)> {
> > +        let data = self.data.clone();
> > +        let mut n_most_common = data.move_iter().collect::<Vec<(K, uint)>>();
> > +        n_most_common.sort_by(|&(_, a), &(_, b)| b.cmp(&a));
> > +        n_most_common.truncate(n);
> > +        n_most_common
> > +    }
> > +
> > +    /// Returns a vector with containing each element the same number of times
> > +    /// as its count.
> > +    // FIXME(schmee): Return FlatMap
> > +    pub fn elements(&self) -> Vec<K> {
>
> I've tried every conceivable combination but I still can't get it working.
> Either I am stupid or this is harder than it needs to be (possibly both,
> but most likely the first). FlatMap<'a,(K,uint), ???, Take<Repeat<K>>>?
> Also, what are the changes in store that would make this simpler?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/mozilla/rust/pull/14443/files#r13143592>
> .
>



-- 
http://octayn.net/