]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/where.rs
rustdoc: use a newline instead of `<br>` to format code headers
[rust.git] / tests / rustdoc / where.rs
1 #![crate_name = "foo"]
2
3 use std::io::Lines;
4
5 pub trait MyTrait { fn dummy(&self) { } }
6
7 // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait"
8 pub struct Alpha<A>(A) where A: MyTrait;
9 // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait"
10 pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); }
11 // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>()where C: MyTrait"
12 pub fn charlie<C>() where C: MyTrait {}
13
14 pub struct Delta<D>(D);
15
16 // @has foo/struct.Delta.html '//*[@class="impl"]//h3[@class="code-header"]' \
17 //          "impl<D> Delta<D>where D: MyTrait"
18 impl<D> Delta<D> where D: MyTrait {
19     pub fn delta() {}
20 }
21
22 pub struct Echo<E>(E);
23
24 // @has 'foo/struct.Simd.html'
25 // @snapshot SWhere_Simd_item-decl - '//pre[@class="rust item-decl"]'
26 pub struct Simd<T>([T; 1])
27 where
28     T: MyTrait;
29
30 // @has 'foo/trait.TraitWhere.html'
31 // @snapshot SWhere_TraitWhere_item-decl - '//pre[@class="rust item-decl"]'
32 pub trait TraitWhere {
33     type Item<'a> where Self: 'a;
34
35     fn func(self)
36     where
37         Self: Sized
38     {}
39
40     fn lines(self) -> Lines<Self>
41     where
42         Self: Sized,
43     { todo!() }
44
45     fn merge<T>(self, a: T)
46     where
47         Self: Sized,
48         T: Sized,
49     { todo!() }
50 }
51
52 // @has foo/struct.Echo.html '//*[@class="impl"]//h3[@class="code-header"]' \
53 //          "impl<E> MyTrait for Echo<E>where E: MyTrait"
54 // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \
55 //          "impl<E> MyTrait for Echo<E>where E: MyTrait"
56 impl<E> MyTrait for Echo<E>where E: MyTrait {}
57
58 pub enum Foxtrot<F> { Foxtrot1(F) }
59
60 // @has foo/enum.Foxtrot.html '//*[@class="impl"]//h3[@class="code-header"]' \
61 //          "impl<F> MyTrait for Foxtrot<F>where F: MyTrait"
62 // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \
63 //          "impl<F> MyTrait for Foxtrot<F>where F: MyTrait"
64 impl<F> MyTrait for Foxtrot<F>where F: MyTrait {}
65
66 // @has foo/type.Golf.html '//pre[@class="rust item-decl"]' \
67 //          "type Golf<T>where T: Clone, = (T, T)"
68 pub type Golf<T> where T: Clone = (T, T);