From ca99aaa053c7915633a1b2dadd40ad0deb3a3ac3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Jun 2021 20:58:05 +0300 Subject: internal: add From to minicore --- crates/test_utils/src/minicore.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/test_utils/src') 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 @@ //! iterator: option //! iterators: iterator //! default: sized +//! from: sized pub mod marker { // region:sized @@ -46,6 +47,32 @@ pub mod default { } // endregion:default +// region:from +pub mod convert { + pub trait From: Sized { + fn from(_: T) -> Self; + } + pub trait Into: Sized { + fn into(self) -> T; + } + + impl Into for T + where + U: From, + { + fn into(self) -> U { + U::from(self) + } + } + + impl From for T { + fn from(t: T) -> T { + t + } + } +} +// endregion:from + pub mod ops { // region:coerce_unsized mod unsize { @@ -324,6 +351,7 @@ pub mod prelude { ops::{Fn, FnMut, FnOnce}, // :fn option::Option::{self, None, Some}, // :option result::Result::{self, Err, Ok}, // :result + convert::{From, Into}, // :from }; } -- cgit v1.2.3