Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics confusion in docs #15977

Closed
mvdnes opened this issue Jul 25, 2014 · 7 comments
Closed

Generics confusion in docs #15977

mvdnes opened this issue Jul 25, 2014 · 7 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@mvdnes
Copy link
Contributor

mvdnes commented Jul 25, 2014

Description

Recently I was looking in the docs for FilterMap, where it says:

fn filter_map<B>(|B|: 'r -> Option<B>) -> FilterMap<'r, B, B, FilterMap<'a, A, B, T>>

However, it seems that not all B's must be the same type. The definition of filter_map is namely:

fn filter_map<'r, B>(self, f: |A|: 'r -> Option<B>) -> FilterMap<'r, A, B, Self>

I believe this is due to the fact that the function filter_map is implemented for Iterator<A> and that FilterMap implements Iterator<B>.

@bluss
Copy link
Member

bluss commented Jul 25, 2014

Compare with core docs: http://doc.rust-lang.org/core/iter/struct.FilterMap.html

This is issue #15099

@steveklabnik
Copy link
Member

Since #15099 is fixed, I'm closing this. Please let me know if something is changed!

@bluss
Copy link
Member

bluss commented Aug 18, 2014

It looks like it might be a separate issue -- the reported bug still exists, and core and std docs are still not equal for the trait implementations section.

@steveklabnik steveklabnik reopened this Aug 18, 2014
@steveklabnik
Copy link
Member

Apparently so.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 24, 2015
@steveklabnik
Copy link
Member

These signatures have changed entirely, I'm not sure if they're still wrong, but they are slightly different...

@mvdnes
Copy link
Contributor Author

mvdnes commented Jan 24, 2015

Confusion in some form arises in the following code

pub trait MyImpl<A> {
    fn myimpl_fun<B>(&self, _: A) -> Option<B> {
        None
    }   
}

pub struct MyStruct<B> {
    _data: B,
}

impl<B> MyImpl<B> for MyStruct<B> {}

Running the doc, we get

impl<B> MyImpl<B> for MyStruct<B>
    fn myimpl_fun<B>(&self, _: A) -> Option<B>

In this case, the A should actually be a B, and the B's from the function something else.

@alexcrichton
Copy link
Member

I believe this is a dupe of #14072, so closing in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants