/src/test/rustdoc/generic-associated-types/gats.rs
https://gitlab.com/rust-lang/rust · Rust · 34 lines · 17 code · 7 blank · 10 comment · 2 complexity · ef44863984d3859aaa3e29b0700ba388 MD5 · raw file
- #![crate_name = "foo"]
- #![feature(generic_associated_types)]
- // @has foo/trait.LendingIterator.html
- pub trait LendingIterator {
- // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a"
- type Item<'a> where Self: 'a;
- // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \
- // "fn next<'a>(&'a self) -> Self::Item<'a>"
- // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \
- // "Item"
- fn next<'a>(&'a self) -> Self::Item<'a>;
- }
- // @has foo/trait.LendingIterator.html
- // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()"
- impl LendingIterator for () {
- type Item<'a> = ();
- fn next<'a>(&self) -> () {}
- }
- pub struct Infinite<T>(T);
- // @has foo/trait.LendingIterator.html
- // @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a = &'a T"
- impl<T> LendingIterator for Infinite<T> {
- type Item<'a> where Self: 'a = &'a T;
- fn next<'a>(&'a self) -> Self::Item<'a> {
- &self.0
- }
- }