]> git.lizzy.rs Git - rust.git/blob - crates/ide_db/src/helpers/famous_defs_fixture.rs
De Morgan's Law assist now correctly inverts <, <=, >, >=.
[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
19 pub mod default {
20     pub trait Default {
21         fn default() -> Self;
22     }
23 }
24
25 pub mod iter {
26     pub use self::traits::{collect::IntoIterator, iterator::Iterator};
27     mod traits {
28         pub(crate) mod iterator {
29             use crate::option::Option;
30             pub trait Iterator {
31                 type Item;
32                 fn next(&mut self) -> Option<Self::Item>;
33                 fn by_ref(&mut self) -> &mut Self {
34                     self
35                 }
36                 fn take(self, n: usize) -> crate::iter::Take<Self> {
37                     crate::iter::Take { inner: self }
38                 }
39             }
40
41             impl<I: Iterator> Iterator for &mut I {
42                 type Item = I::Item;
43                 fn next(&mut self) -> Option<I::Item> {
44                     (**self).next()
45                 }
46             }
47         }
48         pub(crate) mod collect {
49             pub trait IntoIterator {
50                 type Item;
51             }
52         }
53     }
54
55     pub use self::sources::*;
56     pub(crate) mod sources {
57         use super::Iterator;
58         use crate::option::Option::{self, *};
59         pub struct Repeat<A> {
60             element: A,
61         }
62
63         pub fn repeat<T>(elt: T) -> Repeat<T> {
64             Repeat { element: elt }
65         }
66
67         impl<A> Iterator for Repeat<A> {
68             type Item = A;
69
70             fn next(&mut self) -> Option<A> {
71                 None
72             }
73         }
74     }
75
76     pub use self::adapters::*;
77     pub(crate) mod adapters {
78         use super::Iterator;
79         use crate::option::Option::{self, *};
80         pub struct Take<I> {
81             pub(crate) inner: I,
82         }
83         impl<I> Iterator for Take<I>
84         where
85             I: Iterator,
86         {
87             type Item = <I as Iterator>::Item;
88             fn next(&mut self) -> Option<<I as Iterator>::Item> {
89                 None
90             }
91         }
92     }
93 }
94
95 pub mod ops {
96     #[lang = "fn"]
97     pub trait Fn<Args>: FnMut<Args> {
98         extern "rust-call" fn call(&self, args: Args) -> Self::Output;
99     }
100
101     #[lang = "fn_mut"]
102     pub trait FnMut<Args>: FnOnce<Args> {
103         extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
104     }
105     #[lang = "fn_once"]
106     pub trait FnOnce<Args> {
107         #[lang = "fn_once_output"]
108         type Output;
109         extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
110     }
111 }
112
113 pub mod option {
114     pub enum Option<T> {
115         None,
116         Some(T),
117     }
118 }
119
120 pub mod prelude {
121     pub use crate::{
122         cmp::Ord,
123         convert::From,
124         default::Default,
125         iter::{IntoIterator, Iterator},
126         ops::{Fn, FnMut, FnOnce},
127         option::Option::{self, *},
128     };
129 }
130 #[prelude_import]
131 pub use prelude::*;