]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/generic-associated-types/gats.rs
rustdoc: use a newline instead of `<br>` to format code headers
[rust.git] / tests / rustdoc / generic-associated-types / gats.rs
1 #![crate_name = "foo"]
2
3 // @has foo/trait.LendingIterator.html
4 pub trait LendingIterator {
5     // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a"
6     type Item<'a> where Self: 'a;
7
8     // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \
9     //      "fn next<'a>(&'a self) -> Self::Item<'a>"
10     // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \
11     //      "Item"
12     fn next<'a>(&'a self) -> Self::Item<'a>;
13 }
14
15 // @has foo/trait.LendingIterator.html
16 // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()"
17 impl LendingIterator for () {
18     type Item<'a> = ();
19
20     fn next<'a>(&self) -> () {}
21 }
22
23 pub struct Infinite<T>(T);
24
25 // @has foo/trait.LendingIterator.html
26 // @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T"
27 impl<T> LendingIterator for Infinite<T> {
28     type Item<'a> where Self: 'a = &'a T;
29
30     fn next<'a>(&'a self) -> Self::Item<'a> {
31         &self.0
32     }
33 }