]> git.lizzy.rs Git - rust.git/blob - crates/ide_db/src/helpers/famous_defs_fixture.rs
Merge #9105
[rust.git] / crates / ide_db / src / helpers / famous_defs_fixture.rs
1 //- /libcore.rs crate:core
2 //! Signatures of traits, types and functions from the core lib for use in tests.
3 pub mod cmp {
4
5     pub trait Ord {
6         fn cmp(&self, other: &Self) -> Ordering;
7         fn max(self, other: Self) -> Self;
8         fn min(self, other: Self) -> Self;
9         fn clamp(self, min: Self, max: Self) -> Self;
10     }
11 }
12
13 pub mod convert {
14     pub trait From<T> {
15         fn from(t: T) -> Self;
16     }
17
18     pub trait Into<T> {
19         pub fn into(self) -> T;
20     }
21 }
22
23 pub mod default {
24     pub trait Default {
25         fn default() -> Self;
26     }
27 }
28
29 pub mod iter {
30     pub use self::traits::{collect::IntoIterator, iterator::Iterator};
31     mod traits {
32         pub(crate) mod iterator {
33             use crate::option::Option;
34             pub trait Iterator {
35                 type Item;
36                 fn next(&mut self) -> Option<Self::Item>;
37                 fn by_ref(&mut self) -> &mut Self {
38                     self
39                 }
40                 fn take(self, n: usize) -> crate::iter::Take<Self> {
41                     crate::iter::Take { inner: self }
42                 }
43             }
44
45             impl<I: Iterator> Iterator for &mut I {
46                 type Item = I::Item;
47                 fn next(&mut self) -> Option<I::Item> {
48                     (**self).next()
49                 }
50             }
51         }
52         pub(crate) mod collect {
53             pub trait IntoIterator {
54                 type Item;
55             }
56         }
57     }
58
59     pub use self::sources::*;
60     pub(crate) mod sources {
61         use super::Iterator;
62         use crate::option::Option::{self, *};
63         pub struct Repeat<A> {
64             element: A,
65         }
66
67         pub fn repeat<T>(elt: T) -> Repeat<T> {
68             Repeat { element: elt }
69         }
70
71         impl<A> Iterator for Repeat<A> {
72             type Item = A;
73
74             fn next(&mut self) -> Option<A> {
75                 None
76             }
77         }
78     }
79
80     pub use self::adapters::*;
81     pub(crate) mod adapters {
82         use super::Iterator;
83         use crate::option::Option::{self, *};
84         pub struct Take<I> {
85             pub(crate) inner: I,
86         }
87         impl<I> Iterator for Take<I>
88         where
89             I: Iterator,
90         {
91             type Item = <I as Iterator>::Item;
92             fn next(&mut self) -> Option<<I as Iterator>::Item> {
93                 None
94             }
95         }
96     }
97 }
98
99 pub mod ops {
100     #[lang = "fn"]
101     pub trait Fn<Args>: FnMut<Args> {
102         extern "rust-call" fn call(&self, args: Args) -> Self::Output;
103     }
104
105     #[lang = "fn_mut"]
106     pub trait FnMut<Args>: FnOnce<Args> {
107         extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
108     }
109     #[lang = "fn_once"]
110     pub trait FnOnce<Args> {
111         #[lang = "fn_once_output"]
112         type Output;
113         extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
114     }
115
116     #[lang = "deref"]
117     pub trait Deref {
118         type Target: ?Sized;
119         fn deref(&self) -> &Self::Target;
120     }
121 }
122
123 pub mod option {
124     pub enum Option<T> {
125         None,
126         Some(T),
127     }
128 }
129
130 pub mod prelude {
131     pub mod rust_2018 {
132         pub use crate::{
133             cmp::Ord,
134             convert::{From, Into},
135             default::Default,
136             iter::{IntoIterator, Iterator},
137             ops::{Fn, FnMut, FnOnce},
138             option::Option::{self, *},
139         };
140     }
141 }
142 #[prelude_import]
143 pub use prelude::rust_2018::*;
144 //- /libstd.rs crate:std deps:core
145 //! Signatures of traits, types and functions from the std lib for use in tests.
146
147 /// Docs for return_keyword
148 mod return_keyword {}
149
150 /// Docs for prim_str
151 mod prim_str {}
152
153 pub use core::ops;