From 6748f78cb1f360e2b151ed9eb3e487cf1c61ef0e Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 25 Jul 2012 10:13:37 -0700 Subject: 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. --- src/libsyntax/ext/pipes/pipec.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/libsyntax') 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); -- cgit 1.4.1-3-g733a5