diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-17 19:04:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-17 19:04:38 +0100 |
commit | 84507a0b9c2e8f6e632ad9ec649cd1f21a7e0887 (patch) | |
tree | 0c7bf1f81bd6c6b9b57d0c34acc6dfd16af0b23a /crates/test_utils/src | |
parent | 53d26164c6608fd5149180c91fa49c7cde79706f (diff) | |
parent | ca99aaa053c7915633a1b2dadd40ad0deb3a3ac3 (diff) |
Merge #9317
9317: internal: add From to minicore r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r-- | crates/test_utils/src/minicore.rs | 28 |
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 | ||
27 | pub mod marker { | 28 | pub 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 | ||
51 | pub 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 | |||
49 | pub mod ops { | 76 | pub 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 | ||