diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-07-25 10:13:37 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-07-25 12:12:26 -0700 |
| commit | 6748f78cb1f360e2b151ed9eb3e487cf1c61ef0e (patch) | |
| tree | e610ab3c0aa2b6ffebd3b3495624aa51796eb56c /src/libsyntax | |
| parent | 14adb98b64d45c42c256d56e3f0fd167abd36434 (diff) | |
| download | rust-6748f78cb1f360e2b151ed9eb3e487cf1c61ef0e.tar.gz rust-6748f78cb1f360e2b151ed9eb3e487cf1c61ef0e.zip | |
Polymorphic protocols work well enough to do MapReduce.
I did some horrible things with type variable naming here. It should do the right thing in most cases, but we'll need to go through and make it correct someday.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 529a5953dd5..392e6ba392a 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -319,11 +319,12 @@ impl compile of gen_init for protocol { } fn buffer_ty_path(cx: ext_ctxt) -> @ast::ty { - let mut params = ~[]; + let mut params: ~[ast::ty_param] = ~[]; for (copy self.states).each |s| { for s.ty_params.each |tp| { - if !params.contains(tp) { - vec::push(params, tp); + alt params.find(|tpp| *tp.ident == *tpp.ident) { + none { vec::push(params, tp) } + _ { } } } } @@ -334,11 +335,12 @@ impl compile of gen_init for protocol { fn gen_buffer_type(cx: ext_ctxt) -> @ast::item { let ext_cx = cx; - let mut params = ~[]; + let mut params: ~[ast::ty_param] = ~[]; let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { - if !params.contains(tp) { - vec::push(params, tp); + alt params.find(|tpp| *tp.ident == *tpp.ident) { + none { vec::push(params, tp) } + _ { } } } let ty = s.to_ty(cx); |
