Skip to main content

lib2/
lib.rs

1// ignore-tidy-file-linelength
2
3#![feature(doc_cfg, negative_impls, doc_notable_trait)]
4
5pub mod another_folder;
6pub mod another_mod;
7
8pub mod module {
9    pub mod sub_module {
10        pub mod sub_sub_module {
11            pub fn foo() {}
12        }
13        pub fn bar() {}
14    }
15    pub fn whatever() {}
16}
17
18pub fn foobar() {}
19
20pub type Alias = u32;
21
22#[doc(cfg(feature = "foo-method"))]
23pub struct Foo {
24    pub x: Alias,
25}
26
27impl Foo {
28    /// Some documentation
29    /// # A Heading
30    pub fn a_method(&self) {}
31
32    #[cfg(all(
33        feature = "Win32",
34        feature = "Win32_System",
35        feature = "Win32_System_Diagnostics",
36        feature = "Win32_System_Diagnostics_Debug"
37    ))]
38    pub fn lot_of_features() {}
39}
40
41#[doc(cfg(feature = "foo-method"))]
42#[deprecated = "Whatever [`Foo::a_method`](#method.a_method)"]
43pub trait Trait {
44    type X;
45    const Y: u32;
46
47    #[deprecated = "Whatever [`Foo`](#tadam)"]
48    fn foo() {}
49    fn fooo();
50}
51
52impl Trait for Foo {
53    type X = u32;
54    const Y: u32 = 0;
55
56    fn fooo() {}
57}
58
59impl implementors::Whatever for Foo {
60    type Foo = u32;
61}
62
63impl !implementors::Whatever for StructToImplOnReexport {}
64
65#[doc(inline)]
66pub use implementors::TraitToReexport;
67
68pub struct StructToImplOnReexport;
69
70impl TraitToReexport for StructToImplOnReexport {}
71
72pub mod sub_mod {
73    /// ```txt
74    /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
75    /// ```
76    ///
77    /// ```
78    /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
79    /// ```
80    pub struct Foo;
81}
82
83pub mod long_trait {
84    use std::ops::DerefMut;
85
86    pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem:
87        DerefMut<Target = u32> + From<u128> + Send + Sync + AsRef<str> + 'static
88    {
89    }
90}
91
92pub mod long_table {
93    /// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two |
94    /// | ----------- | ----------- | ----------- | ----------- |
95    /// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two |
96    ///
97    /// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq
98    pub struct Foo;
99
100    /// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two |
101    /// | ----------- | ----------- | ----------- | ----------- |
102    /// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two |
103    ///
104    /// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq
105    impl Foo {
106        pub fn foo(&self) {}
107    }
108}
109
110pub mod summary_table {
111    /// | header 1 | header 2 |
112    /// | -------- | -------- |
113    /// | content | content |
114    pub struct Foo;
115}
116
117pub mod too_long {
118    pub type ReallyLongTypeNameLongLongLong =
119        Option<unsafe extern "C" fn(a: *const u8, b: *const u8) -> *const u8>;
120
121    /// Short doc.
122    pub const ReallyLongTypeNameLongLongLongConstBecauseWhyNotAConstRightGigaGigaSupraLong: u32 = 0;
123
124    /// This also has a really long doccomment. Lorem ipsum dolor sit amet,
125    /// consectetur adipiscing elit. Suspendisse id nibh malesuada, hendrerit
126    /// massa vel, tincidunt est. Nulla interdum, sem ac efficitur ornare, arcu
127    /// nunc dignissim nibh, at rutrum diam augue ac mauris. Fusce tincidunt et
128    /// ligula sed viverra. Aenean sed facilisis dui, non volutpat felis. In
129    /// vitae est dui. Donec felis nibh, blandit at nibh eu, tempor suscipit
130    /// nisl. Vestibulum ornare porta libero, eu faucibus purus iaculis ut. Ut
131    /// quis tincidunt nunc, in mollis purus. Nulla sed interdum quam. Nunc
132    /// vitae cursus ex.
133    pub struct SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName {
134        pub a: u32,
135    }
136
137    impl SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName {
138        /// ```
139        /// let x = SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName { a: 0 };
140        /// ```
141        pub fn foo(&self) {}
142    }
143}
144
145pub struct HasALongTraitWithParams {}
146
147pub trait LongTraitWithParamsBananaBananaBanana<T> {}
148
149impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {}
150
151#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
152pub struct LongItemInfo;
153
154pub trait SimpleTrait {}
155pub struct LongItemInfo2;
156
157/// Some docs.
158#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
159impl SimpleTrait for LongItemInfo2 {}
160
161pub struct WhereWhitespace<T>(T);
162
163impl<T> WhereWhitespace<T> {
164    pub fn new<F>(f: F) -> Self
165    where
166        F: FnMut() -> i32,
167    {todo!()}
168}
169
170impl<K, T> Whitespace<&K> for WhereWhitespace<T>
171where
172    K: std::fmt::Debug,
173{
174    type Output = WhereWhitespace<T>;
175    fn index(&self, _key: &K) -> &Self::Output {
176        self
177    }
178}
179
180pub trait Whitespace<Idx>
181where
182    Idx: ?Sized,
183{
184    type Output;
185    fn index(&self, index: Idx) -> &Self::Output;
186}
187
188pub struct ItemInfoAlignmentTest;
189
190impl ItemInfoAlignmentTest {
191    /// This method has docs
192    #[deprecated]
193    pub fn foo() {}
194    #[deprecated]
195    pub fn bar() {}
196}
197
198pub mod scroll_traits {
199    use std::iter::*;
200
201    struct Intersperse<T>(T);
202    struct IntersperseWith<T, U>(T, U);
203    struct Flatten<T>(T);
204    struct Peekable<T>(T);
205
206    /// Shamelessly (partially) copied from `std::iter::Iterator`.
207    /// It allows us to check that the scroll is working as expected on "hidden" items.
208    pub trait Iterator {
209        type Item;
210
211        fn next(&mut self) -> Option<Self::Item>;
212        fn size_hint(&self) -> (usize, Option<usize>);
213        fn count(self) -> usize
214        where
215            Self: Sized;
216        fn last(self) -> Option<Self::Item>
217        where
218            Self: Sized;
219        fn advance_by(&mut self, n: usize) -> Result<(), usize>;
220        fn nth(&mut self, n: usize) -> Option<Self::Item>;
221        fn step_by(self, step: usize) -> StepBy<Self>
222        where
223            Self: Sized;
224        fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
225        where
226            Self: Sized,
227            U: IntoIterator<Item = Self::Item>;
228        fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
229        where
230            Self: Sized,
231            U: IntoIterator;
232        fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
233        where
234            Self: Sized,
235            Self::Item: Clone;
236        fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
237        where
238            Self: Sized,
239            G: FnMut() -> Self::Item;
240        fn map<B, F>(self, f: F) -> Map<Self, F>
241        where
242            Self: Sized,
243            F: FnMut(Self::Item) -> B;
244        fn for_each<F>(self, f: F)
245        where
246            Self: Sized,
247            F: FnMut(Self::Item);
248        fn filter<P>(self, predicate: P) -> Filter<Self, P>
249        where
250            Self: Sized,
251            P: FnMut(&Self::Item) -> bool;
252        fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
253        where
254            Self: Sized,
255            F: FnMut(Self::Item) -> Option<B>;
256        fn enumerate(self) -> Enumerate<Self>
257        where
258            Self: Sized;
259        fn peekable(self) -> Peekable<Self>
260        where
261            Self: Sized;
262        fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
263        where
264            Self: Sized,
265            P: FnMut(&Self::Item) -> bool;
266        fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
267        where
268            Self: Sized,
269            P: FnMut(&Self::Item) -> bool;
270        fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
271        where
272            Self: Sized,
273            P: FnMut(Self::Item) -> Option<B>;
274        fn skip(self, n: usize) -> Skip<Self>
275        where
276            Self: Sized;
277        fn take(self, n: usize) -> Take<Self>
278        where
279            Self: Sized;
280        fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
281        where
282            Self: Sized,
283            F: FnMut(&mut St, Self::Item) -> Option<B>;
284        fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
285        where
286            Self: Sized,
287            U: IntoIterator,
288            F: FnMut(Self::Item) -> U;
289        fn flatten(self) -> Flatten<Self>
290        where
291            Self: Sized,
292            Self::Item: IntoIterator;
293        fn fuse(self) -> Fuse<Self>
294        where
295            Self: Sized;
296        fn inspect<F>(self, f: F) -> Inspect<Self, F>
297        where
298            Self: Sized,
299            F: FnMut(&Self::Item);
300        fn by_ref(&mut self) -> &mut Self
301        where
302            Self: Sized;
303        fn collect<B: FromIterator<Self::Item>>(self) -> B
304        where
305            Self: Sized;
306        fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
307        where
308            Self: Sized;
309        fn partition<B, F>(self, f: F) -> (B, B)
310        where
311            Self: Sized,
312            B: Default + Extend<Self::Item>,
313            F: FnMut(&Self::Item) -> bool;
314        fn partition_in_place<'a, T: 'a, P>(mut self, predicate: P) -> usize
315        where
316            Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
317            P: FnMut(&T) -> bool;
318        fn is_partitioned<P>(mut self, mut predicate: P) -> bool
319        where
320            Self: Sized,
321            P: FnMut(Self::Item) -> bool;
322        fn fold<B, F>(mut self, init: B, mut f: F) -> B
323        where
324            Self: Sized,
325            F: FnMut(B, Self::Item) -> B;
326        fn reduce<F>(mut self, f: F) -> Option<Self::Item>
327        where
328            Self: Sized,
329            F: FnMut(Self::Item, Self::Item) -> Self::Item;
330        fn all<F>(&mut self, f: F) -> bool
331        where
332            Self: Sized,
333            F: FnMut(Self::Item) -> bool;
334        fn any<F>(&mut self, f: F) -> bool
335        where
336            Self: Sized,
337            F: FnMut(Self::Item) -> bool;
338        fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
339        where
340            Self: Sized,
341            P: FnMut(&Self::Item) -> bool;
342        fn find_map<B, F>(&mut self, f: F) -> Option<B>
343        where
344            Self: Sized,
345            F: FnMut(Self::Item) -> Option<B>;
346        fn position<P>(&mut self, predicate: P) -> Option<usize>
347        where
348            Self: Sized,
349            P: FnMut(Self::Item) -> bool;
350        /// We will scroll to "string" to ensure it scrolls as expected.
351        fn this_is_a_method_with_a_long_name_returning_something() -> String;
352    }
353
354    /// This one doesn't have hidden items (because there are too many) so we can also confirm that it
355    /// scrolls as expected.
356    pub trait TraitWithLongItemsName {
357        fn this_is_a_method_with_a_long_name_returning_something() -> String;
358    }
359}
360
361pub struct Derefer(String);
362
363impl std::ops::Deref for Derefer {
364    type Target = str;
365
366    fn deref(&self) -> &Self::Target {
367        &self.0
368    }
369}
370
371pub mod deprecated {
372    #[deprecated(since = "1.26.0", note = "deprecated")]
373    pub struct DeprecatedStruct;
374
375    pub struct NonDeprecatedStruct;
376
377    pub trait NormalTrait {
378        #[deprecated(since = "1.26.0", note = "deprecated")]
379        /// doc
380        const X: usize = 12;
381
382        #[deprecated(since = "1.26.0", note = "deprecated")]
383        /// doc
384        fn normal_deprecated_fn();
385    }
386
387    #[deprecated(since = "1.26.0", note = "deprecated")]
388    pub trait DeprecatedTrait {
389        fn depr_deprecated_fn();
390    }
391
392    impl NonDeprecatedStruct {
393        #[deprecated(since = "1.26.0", note = "deprecated")]
394        /// doc
395        pub fn deprecated_fn() {}
396
397        /// doc
398        pub fn non_deprecated_fn() {}
399
400        #[deprecated(since = "TBD", note = "deprecated")]
401        /// doc
402        pub fn future_deprecated_fn() {}
403    }
404
405    impl NormalTrait for NonDeprecatedStruct {
406        fn normal_deprecated_fn() {}
407    }
408
409    impl DeprecatedTrait for NonDeprecatedStruct {
410        fn depr_deprecated_fn() {}
411    }
412}
413
414pub mod notable_trait_colors {
415    /// Top doc
416    pub struct NotableTraitColors;
417    #[doc(notable_trait(color="grey"))]
418    pub trait Grey {}
419    impl Grey for NotableTraitColors {}
420    #[doc(notable_trait(color="red"))]
421    pub trait Red {}
422    impl Red for NotableTraitColors {}
423    #[doc(notable_trait(color="green"))]
424    pub trait Green {}
425    impl Green for NotableTraitColors {}
426    #[doc(notable_trait(color="yellow"))]
427    pub trait Yellow {}
428    impl Yellow for NotableTraitColors {}
429    #[doc(notable_trait(color="blue"))]
430    pub trait Blue {}
431    impl Blue for NotableTraitColors {}
432    #[doc(notable_trait(color="magenta"))]
433    pub trait Magenta {}
434    impl Magenta for NotableTraitColors {}
435    #[doc(notable_trait(color="cyan"))]
436    pub trait Cyan {}
437    impl Cyan for NotableTraitColors {}
438    #[doc(notable_trait(color="transparent"))]
439    pub trait Transparent {}
440    impl Transparent for NotableTraitColors {}
441}