]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/assoc-types.rs
Auto merge of #31700 - oli-obk:skip_double_ended, r=alexcrichton
[rust.git] / src / test / rustdoc / assoc-types.rs
1 // Copyright 2015 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.
4 //
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.
10
11 #![crate_type="lib"]
12
13 // @has assoc_types/trait.Index.html
14 pub trait Index<I: ?Sized> {
15     // @has - '//*[@id="associatedtype.Output"]//code' 'type Output: ?Sized'
16     type Output: ?Sized;
17     // @has - '//*[@id="tymethod.index"]//code' \
18     //      "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
19     fn index<'a>(&'a self, index: I) -> &'a Self::Output;
20 }
21
22 // @has assoc_types/fn.use_output.html
23 // @has - '//*[@class="rust fn"]' '-> &T::Output'
24 pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
25     obj.index(index)
26 }
27
28 pub trait Feed {
29     type Input;
30 }
31
32 // @has assoc_types/fn.use_input.html
33 // @has - '//*[@class="rust fn"]' 'T::Input'
34 pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
35
36 // @has assoc_types/fn.cmp_input.html
37 // @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
38 pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
39     where T::Input: PartialEq<U::Input>
40 {
41     a == b
42 }