aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-17 18:58:05 +0100
committerAleksey Kladov <[email protected]>2021-06-17 19:04:12 +0100
commitca99aaa053c7915633a1b2dadd40ad0deb3a3ac3 (patch)
tree0c7bf1f81bd6c6b9b57d0c34acc6dfd16af0b23a /crates/test_utils
parent82c7afc70354c15454207ef8ffd2f7274330c3ed (diff)
internal: add From to minicore
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/minicore.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs
index 4093a04bc..a5a7c2f7d 100644
--- a/crates/test_utils/src/minicore.rs
+++ b/crates/test_utils/src/minicore.rs
@@ -23,6 +23,7 @@
23//! iterator: option 23//! iterator: option
24//! iterators: iterator 24//! iterators: iterator
25//! default: sized 25//! default: sized
26//! from: sized
26 27
27pub mod marker { 28pub mod marker {
28 // region:sized 29 // region:sized
@@ -46,6 +47,32 @@ pub mod default {
46} 47}
47// endregion:default 48// endregion:default
48 49
50// region:from
51pub mod convert {
52 pub trait From<T>: Sized {
53 fn from(_: T) -> Self;
54 }
55 pub trait Into<T>: Sized {
56 fn into(self) -> T;
57 }
58
59 impl<T, U> Into<U> for T
60 where
61 U: From<T>,
62 {
63 fn into(self) -> U {
64 U::from(self)
65 }
66 }
67
68 impl<T> From<T> for T {
69 fn from(t: T) -> T {
70 t
71 }
72 }
73}
74// endregion:from
75
49pub mod ops { 76pub mod ops {
50 // region:coerce_unsized 77 // region:coerce_unsized
51 mod unsize { 78 mod unsize {
@@ -324,6 +351,7 @@ pub mod prelude {
324 ops::{Fn, FnMut, FnOnce}, // :fn 351 ops::{Fn, FnMut, FnOnce}, // :fn
325 option::Option::{self, None, Some}, // :option 352 option::Option::{self, None, Some}, // :option
326 result::Result::{self, Err, Ok}, // :result 353 result::Result::{self, Err, Ok}, // :result
354 convert::{From, Into}, // :from
327 }; 355 };
328 } 356 }
329 357