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