internal: add From to minicore

This commit is contained in:
Aleksey Kladov 2021-06-17 20:58:05 +03:00
parent 82c7afc703
commit ca99aaa053
5 changed files with 129 additions and 62 deletions

View file

@ -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<T>: Sized {
fn from(_: T) -> Self;
}
pub trait Into<T>: Sized {
fn into(self) -> T;
}
impl<T, U> Into<U> for T
where
U: From<T>,
{
fn into(self) -> U {
U::from(self)
}
}
impl<T> From<T> 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
};
}