]> git.proxmox.com Git - rustc.git/blob - src/test/rustdoc/assoc-types.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / rustdoc / assoc-types.rs
1 // ignore-tidy-linelength
2
3 #![crate_type="lib"]
4
5 // @has assoc_types/trait.Index.html
6 pub trait Index<I: ?Sized> {
7 // @has - '//*[@id="associatedtype.Output"]//code' 'type Output: ?Sized'
8 type Output: ?Sized;
9 // @has - '//*[@id="tymethod.index"]//code' \
10 // "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
11 // @has - '//*[@id="tymethod.index"]//code//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' \
12 // "Output"
13 fn index<'a>(&'a self, index: I) -> &'a Self::Output;
14 }
15
16 // @has assoc_types/fn.use_output.html
17 // @has - '//*[@class="rust fn"]' '-> &T::Output'
18 // @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' 'Output'
19 pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
20 obj.index(index)
21 }
22
23 pub trait Feed {
24 type Input;
25 }
26
27 // @has assoc_types/fn.use_input.html
28 // @has - '//*[@class="rust fn"]' 'T::Input'
29 // @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
30 pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
31
32 // @has assoc_types/fn.cmp_input.html
33 // @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
34 // @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
35 pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
36 where T::Input: PartialEq<U::Input>
37 {
38 a == b
39 }