mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
internal: add From to minicore
This commit is contained in:
parent
82c7afc703
commit
ca99aaa053
5 changed files with 129 additions and 62 deletions
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue