aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-12 16:26:08 +0000
committerLukas Wirth <[email protected]>2021-01-12 16:26:08 +0000
commite9e3ab549d5a73f85e19eed5b915d78870f8892c (patch)
tree10f8792c8b532bdd4854220f3656130407c6ec67 /crates/ide_db/src/helpers
parent52fa926f005890f07dffc789c84c2be57a6bdccc (diff)
Move FamousDefs fixture out into its own file
Diffstat (limited to 'crates/ide_db/src/helpers')
-rw-r--r--crates/ide_db/src/helpers/famous_defs_fixture.rs119
1 files changed, 119 insertions, 0 deletions
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs
new file mode 100644
index 000000000..f3d355861
--- /dev/null
+++ b/crates/ide_db/src/helpers/famous_defs_fixture.rs
@@ -0,0 +1,119 @@
1//- /libcore.rs crate:core
2pub mod convert {
3 pub trait From<T> {
4 fn from(t: T) -> Self;
5 }
6}
7
8pub mod default {
9 pub trait Default {
10 fn default() -> Self;
11 }
12}
13
14pub mod iter {
15 pub use self::traits::{collect::IntoIterator, iterator::Iterator};
16 mod traits {
17 pub(crate) mod iterator {
18 use crate::option::Option;
19 pub trait Iterator {
20 type Item;
21 fn next(&mut self) -> Option<Self::Item>;
22 fn by_ref(&mut self) -> &mut Self {
23 self
24 }
25 fn take(self, n: usize) -> crate::iter::Take<Self> {
26 crate::iter::Take { inner: self }
27 }
28 }
29
30 impl<I: Iterator> Iterator for &mut I {
31 type Item = I::Item;
32 fn next(&mut self) -> Option<I::Item> {
33 (**self).next()
34 }
35 }
36 }
37 pub(crate) mod collect {
38 pub trait IntoIterator {
39 type Item;
40 }
41 }
42 }
43
44 pub use self::sources::*;
45 pub(crate) mod sources {
46 use super::Iterator;
47 use crate::option::Option::{self, *};
48 pub struct Repeat<A> {
49 element: A,
50 }
51
52 pub fn repeat<T>(elt: T) -> Repeat<T> {
53 Repeat { element: elt }
54 }
55
56 impl<A> Iterator for Repeat<A> {
57 type Item = A;
58
59 fn next(&mut self) -> Option<A> {
60 None
61 }
62 }
63 }
64
65 pub use self::adapters::*;
66 pub(crate) mod adapters {
67 use super::Iterator;
68 use crate::option::Option::{self, *};
69 pub struct Take<I> {
70 pub(crate) inner: I,
71 }
72 impl<I> Iterator for Take<I>
73 where
74 I: Iterator,
75 {
76 type Item = <I as Iterator>::Item;
77 fn next(&mut self) -> Option<<I as Iterator>::Item> {
78 None
79 }
80 }
81 }
82}
83
84pub mod ops {
85 #[lang = "fn"]
86 pub trait Fn<Args>: FnMut<Args> {
87 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
88 }
89
90 #[lang = "fn_mut"]
91 pub trait FnMut<Args>: FnOnce<Args> {
92 extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
93 }
94 #[lang = "fn_once"]
95 pub trait FnOnce<Args> {
96 #[lang = "fn_once_output"]
97 type Output;
98 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
99 }
100}
101
102pub mod option {
103 pub enum Option<T> {
104 None,
105 Some(T),
106 }
107}
108
109pub mod prelude {
110 pub use crate::{
111 convert::From,
112 default::Default,
113 iter::{IntoIterator, Iterator},
114 ops::{Fn, FnMut, FnOnce},
115 option::Option::{self, *},
116 };
117}
118#[prelude_import]
119pub use prelude::*;