Skip to content

Conversation

@brendanzab
Copy link
Contributor

Adds a zero-sized type hint that can be used to access static methods that don't mention Self. For example:

trait A {
    fn a(_: ForType<Self>) -> uint;
}

impl A for int {
    fn a(_: ForType<int>) -> uint { 6 }
}

assert_eq!(A::a(ForType::<int>), 6);

Previously Option<Self> was usually used, but this makes the intent clearer.

@thestinger
Copy link
Contributor

I really think we need to fix the language here, rather than working around it more. I know @pcwalton really hates the idea of making :: lookup magical but the library is ending up filled with ugly workarounds.

@brendanzab
Copy link
Contributor Author

@thestinger Yeah. But as an interim fix? I could maybe add a FIXME referencing #8888 and #6894.

@sfackler
Copy link
Member

sfackler commented Nov 9, 2013

Is there any reason that the A::<for int>::a() syntax hasn't been added? I thought that that was the planned fix for this.

@brendanzab
Copy link
Contributor Author

@sfackler see the issues mentioned above: #6894 and #8888

@alexcrichton
Copy link
Member

I would personally much rather see an actual fix for this issue (something along the A::<for int>::a() syntax) rather than a band-aid over the actual problem. It seems like we've already got enough band-aids as is and it's always sad to add more if we can avoid it.

@alexcrichton
Copy link
Member

Closing due to inactivity, and I also believe that this would be better served with actually fixing the language rather than having these type hint structures.

@brendanzab brendanzab deleted the type-hint branch January 2, 2014 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants