]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/intra-doc/generic-params.rs
rustdoc: link to stable/beta docs consistently in documentation
[rust.git] / src / test / rustdoc / intra-doc / generic-params.rs
1 // ignore-tidy-linelength
2
3 #![crate_name = "foo"]
4
5 //! Here's a link to [`Vec<T>`] and one to [`Box<Vec<Option<T>>>`].
6 //! Here's a link to [`Iterator<Box<T>>::Item`].
7 //!
8 // @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html"]' 'Vec<T>'
9 // @has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'Box<Vec<Option<T>>>'
10 // @has foo/index.html '//a[@href="{{channel}}/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item"]' 'Iterator<Box<T>>::Item'
11
12 //! And what about a link to [just `Option`](Option) and, [with the generic, `Option<T>`](Option<T>)?
13 //!
14 // @has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'just Option'
15 // @has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'with the generic, Option<T>'
16
17 //! We should also try linking to [`Result<T, E>`]; it has *two* generics!
18 //! And [`Result<T, !>`] and [`Result<!, E>`].
19 //!
20 // @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, E>'
21 // @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, !>'
22 // @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<!, E>'
23
24 //! Now let's test a trickier case: [`Vec::<T>::new`], or you could write it
25 //! [with parentheses as `Vec::<T>::new()`][Vec::<T>::new()].
26 //! And what about something even harder? That would be [`Vec::<Box<T>>::new()`].
27 //!
28 // @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<T>::new'
29 // @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'with parentheses as Vec::<T>::new()'
30 // @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<Box<T>>::new()'
31
32 //! This is also pretty tricky: [`TypeId::of::<String>()`].
33 //! And this too: [`Vec::<std::error::Error>::len`].
34 //!
35 // @has foo/index.html '//a[@href="{{channel}}/core/any/struct.TypeId.html#method.of"]' 'TypeId::of::<String>()'
36 // @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.len"]' 'Vec::<std::error::Error>::len'
37
38 //! We unofficially and implicitly support things that aren't valid in the actual Rust syntax, like
39 //! [`Box::<T>new()`]. We may not support them in the future!
40 //!
41 // @has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html#method.new"]' 'Box::<T>new()'
42
43 //! These will be resolved as regular links:
44 //! - [`this is <invalid syntax> first`](https://www.rust-lang.org)
45 //! - [`this is <invalid syntax> twice`]
46 //! - [`<invalid syntax> thrice`](https://www.rust-lang.org)
47 //! - [`<invalid syntax> four times`][rlo]
48 //! - [a < b][rlo]
49 //! - [c > d]
50 //!
51 //! [`this is <invalid syntax> twice`]: https://www.rust-lang.org
52 //! [rlo]: https://www.rust-lang.org
53 //! [c > d]: https://www.rust-lang.org
54 //!
55 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> first'
56 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> twice'
57 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> thrice'
58 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> four times'
59 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'a < b'
60 // @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'c > d'
61
62 use std::any::TypeId;