1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that we are able to compile calls to associated fns like
12 // `decode()` where the bound on the `Self` parameter references a
13 // lifetime parameter of the trait. This example indicates why trait
14 // lifetime parameters must be early bound in the type of the
24 pub trait Decoder<'v> {
25 fn read(&mut self) -> Value<'v>;
28 pub trait Decodable<'v, D: Decoder<'v>>
29 : marker::PhantomFn<(), &'v int>
31 fn decode(d: &mut D) -> Self;
34 impl<'v, D: Decoder<'v>> Decodable<'v, D> for () {
35 fn decode(d: &mut D) -> () {
38 Value::B => Decodable::decode(d),