Last active
March 15, 2016 13:42
-
-
Save txus/78ea363da278d953a0de to your computer and use it in GitHub Desktop.
Is there a way to have enum branches that introduce their own type parameters?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Hey { | |
fn ha(&self) -> u32; | |
} | |
enum Foo<A> { | |
Ret(A), | |
Bar<X: Hey>(Box<Fn(X) -> Foo<A>>) | |
} | |
fn test() -> Foo<u32> { | |
Foo::Bar(Box::new(|x| { | |
Foo::Bar(Box::new(|y| { | |
Foo::Ret(ha(y) + ha(x)) | |
}))) | |
} | |
// actual code | |
enum HttpClient<R, Req: FromHttpRequest> { | |
Return(R), | |
Send(Req, Box<Fn(String) -> HttpClient<R, Req>>), | |
Parse(String, Box<Fn(ParseResult) -> HttpClient<R, Req>>) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment