aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-17 22:30:22 +0100
committerAleksey Kladov <[email protected]>2021-06-17 22:30:22 +0100
commitebb591a5704f767d783d57af7022272f665318ac (patch)
tree76a5268851cf7b79447d5de79514c0d0b579e823 /crates/test_utils
parent9b013ffcae672595aeb1aee9de907e05fb7ca065 (diff)
internal: add derive and ord support to minicore
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/minicore.rs62
1 files changed, 61 insertions, 1 deletions
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs
index a5a7c2f7d..9ec541c57 100644
--- a/crates/test_utils/src/minicore.rs
+++ b/crates/test_utils/src/minicore.rs
@@ -24,6 +24,9 @@
24//! iterators: iterator 24//! iterators: iterator
25//! default: sized 25//! default: sized
26//! from: sized 26//! from: sized
27//! eq: sized
28//! ord: eq, option
29//! derive:
27 30
28pub mod marker { 31pub mod marker {
29 // region:sized 32 // region:sized
@@ -173,6 +176,49 @@ pub mod ops {
173 // endregion:fn 176 // endregion:fn
174} 177}
175 178
179// region:eq
180pub mod cmp {
181 #[lang = "eq"]
182 pub trait PartialEq<Rhs: ?Sized = Self> {
183 fn eq(&self, other: &Rhs) -> bool;
184 }
185
186 pub trait Eq: PartialEq<Self> {}
187
188 // region:derive
189 #[rustc_builtin_macro]
190 pub macro PartialEq($item:item) {}
191 #[rustc_builtin_macro]
192 pub macro Eq($item:item) {}
193 // endregion:derive
194
195 // region:ord
196 #[lang = "partial_ord"]
197 pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
198 fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
199 }
200
201 pub trait Ord: Eq + PartialOrd<Self> {
202 fn cmp(&self, other: &Self) -> Ordering;
203 }
204
205 pub enum Ordering {
206 Less = -1,
207 Equal = 0,
208 Greater = 1,
209 }
210
211 // region:derive
212 #[rustc_builtin_macro]
213 pub macro PartialOrd($item:item) {}
214 #[rustc_builtin_macro]
215 pub macro Ord($item:item) {}
216 // endregion:derive
217
218 // endregion:ord
219}
220// endregion:eq
221
176// region:slice 222// region:slice
177pub mod slice { 223pub mod slice {
178 #[lang = "slice"] 224 #[lang = "slice"]
@@ -342,16 +388,30 @@ pub mod iter {
342} 388}
343// endregion:iterator 389// endregion:iterator
344 390
391// region:derive
392mod macros {
393 pub(crate) mod builtin {
394 #[rustc_builtin_macro]
395 pub macro derive($item:item) {
396 /* compiler built-in */
397 }
398 }
399}
400// endregion:derive
401
345pub mod prelude { 402pub mod prelude {
346 pub mod v1 { 403 pub mod v1 {
347 pub use crate::{ 404 pub use crate::{
405 cmp::{Eq, PartialEq}, // :eq
406 cmp::{Ord, PartialOrd}, // :ord
407 convert::{From, Into}, // :from
348 default::Default, // :default 408 default::Default, // :default
349 iter::{IntoIterator, Iterator}, // :iterator 409 iter::{IntoIterator, Iterator}, // :iterator
410 macros::builtin::derive, // :derive
350 marker::Sized, // :sized 411 marker::Sized, // :sized
351 ops::{Fn, FnMut, FnOnce}, // :fn 412 ops::{Fn, FnMut, FnOnce}, // :fn
352 option::Option::{self, None, Some}, // :option 413 option::Option::{self, None, Some}, // :option
353 result::Result::{self, Err, Ok}, // :result 414 result::Result::{self, Err, Ok}, // :result
354 convert::{From, Into}, // :from
355 }; 415 };
356 } 416 }
357 417