minor: use minicore
This commit is contained in:
parent
90da9fc9b3
commit
3762cc7465
@ -13,10 +13,7 @@
|
|||||||
// Converts an Into impl to an equivalent From impl.
|
// Converts an Into impl to an equivalent From impl.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
// # //- /lib.rs crate:core
|
// # //- minicore: from
|
||||||
// # pub mod convert { pub trait Into<T> { pub fn into(self) -> T; } }
|
|
||||||
// # //- /lib.rs crate:main deps:core
|
|
||||||
// # use core::convert::Into;
|
|
||||||
// impl $0Into<Thing> for usize {
|
// impl $0Into<Thing> for usize {
|
||||||
// fn into(self) -> Thing {
|
// fn into(self) -> Thing {
|
||||||
// Thing {
|
// Thing {
|
||||||
@ -28,7 +25,6 @@
|
|||||||
// ```
|
// ```
|
||||||
// ->
|
// ->
|
||||||
// ```
|
// ```
|
||||||
// # use core::convert::Into;
|
|
||||||
// impl From<usize> for Thing {
|
// impl From<usize> for Thing {
|
||||||
// fn from(val: usize) -> Self {
|
// fn from(val: usize) -> Self {
|
||||||
// Thing {
|
// Thing {
|
||||||
|
@ -11,14 +11,10 @@
|
|||||||
// Converts an Iterator::for_each function into a for loop.
|
// Converts an Iterator::for_each function into a for loop.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
// # //- /lib.rs crate:core
|
// # //- minicore: iterators
|
||||||
// # pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
|
// # use core::iter;
|
||||||
// # pub struct SomeIter;
|
|
||||||
// # impl self::iter::traits::iterator::Iterator for SomeIter {}
|
|
||||||
// # //- /lib.rs crate:main deps:core
|
|
||||||
// # use core::SomeIter;
|
|
||||||
// fn main() {
|
// fn main() {
|
||||||
// let iter = SomeIter;
|
// let iter = iter::repeat((9, 2));
|
||||||
// iter.for_each$0(|(x, y)| {
|
// iter.for_each$0(|(x, y)| {
|
||||||
// println!("x: {}, y: {}", x, y);
|
// println!("x: {}, y: {}", x, y);
|
||||||
// });
|
// });
|
||||||
@ -26,9 +22,9 @@
|
|||||||
// ```
|
// ```
|
||||||
// ->
|
// ->
|
||||||
// ```
|
// ```
|
||||||
// # use core::SomeIter;
|
// # use core::iter;
|
||||||
// fn main() {
|
// fn main() {
|
||||||
// let iter = SomeIter;
|
// let iter = iter::repeat((9, 2));
|
||||||
// for (x, y) in iter {
|
// for (x, y) in iter {
|
||||||
// println!("x: {}, y: {}", x, y);
|
// println!("x: {}, y: {}", x, y);
|
||||||
// }
|
// }
|
||||||
|
@ -20,17 +20,16 @@
|
|||||||
// Replaces `unwrap` with a `match` expression. Works for Result and Option.
|
// Replaces `unwrap` with a `match` expression. Works for Result and Option.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
// enum Result<T, E> { Ok(T), Err(E) }
|
// # //- minicore: result
|
||||||
// fn main() {
|
// fn main() {
|
||||||
// let x: Result<i32, i32> = Result::Ok(92);
|
// let x: Result<i32, i32> = Ok(92);
|
||||||
// let y = x.$0unwrap();
|
// let y = x.$0unwrap();
|
||||||
// }
|
// }
|
||||||
// ```
|
// ```
|
||||||
// ->
|
// ->
|
||||||
// ```
|
// ```
|
||||||
// enum Result<T, E> { Ok(T), Err(E) }
|
|
||||||
// fn main() {
|
// fn main() {
|
||||||
// let x: Result<i32, i32> = Result::Ok(92);
|
// let x: Result<i32, i32> = Ok(92);
|
||||||
// let y = match x {
|
// let y = match x {
|
||||||
// Ok(it) => it,
|
// Ok(it) => it,
|
||||||
// $0_ => unreachable!(),
|
// $0_ => unreachable!(),
|
||||||
|
@ -209,10 +209,7 @@ fn doctest_convert_into_to_from() {
|
|||||||
check_doc_test(
|
check_doc_test(
|
||||||
"convert_into_to_from",
|
"convert_into_to_from",
|
||||||
r#####"
|
r#####"
|
||||||
//- /lib.rs crate:core
|
//- minicore: from
|
||||||
pub mod convert { pub trait Into<T> { pub fn into(self) -> T; } }
|
|
||||||
//- /lib.rs crate:main deps:core
|
|
||||||
use core::convert::Into;
|
|
||||||
impl $0Into<Thing> for usize {
|
impl $0Into<Thing> for usize {
|
||||||
fn into(self) -> Thing {
|
fn into(self) -> Thing {
|
||||||
Thing {
|
Thing {
|
||||||
@ -223,7 +220,6 @@ fn into(self) -> Thing {
|
|||||||
}
|
}
|
||||||
"#####,
|
"#####,
|
||||||
r#####"
|
r#####"
|
||||||
use core::convert::Into;
|
|
||||||
impl From<usize> for Thing {
|
impl From<usize> for Thing {
|
||||||
fn from(val: usize) -> Self {
|
fn from(val: usize) -> Self {
|
||||||
Thing {
|
Thing {
|
||||||
@ -241,23 +237,19 @@ fn doctest_convert_iter_for_each_to_for() {
|
|||||||
check_doc_test(
|
check_doc_test(
|
||||||
"convert_iter_for_each_to_for",
|
"convert_iter_for_each_to_for",
|
||||||
r#####"
|
r#####"
|
||||||
//- /lib.rs crate:core
|
//- minicore: iterators
|
||||||
pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
|
use core::iter;
|
||||||
pub struct SomeIter;
|
|
||||||
impl self::iter::traits::iterator::Iterator for SomeIter {}
|
|
||||||
//- /lib.rs crate:main deps:core
|
|
||||||
use core::SomeIter;
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let iter = SomeIter;
|
let iter = iter::repeat((9, 2));
|
||||||
iter.for_each$0(|(x, y)| {
|
iter.for_each$0(|(x, y)| {
|
||||||
println!("x: {}, y: {}", x, y);
|
println!("x: {}, y: {}", x, y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
"#####,
|
"#####,
|
||||||
r#####"
|
r#####"
|
||||||
use core::SomeIter;
|
use core::iter;
|
||||||
fn main() {
|
fn main() {
|
||||||
let iter = SomeIter;
|
let iter = iter::repeat((9, 2));
|
||||||
for (x, y) in iter {
|
for (x, y) in iter {
|
||||||
println!("x: {}, y: {}", x, y);
|
println!("x: {}, y: {}", x, y);
|
||||||
}
|
}
|
||||||
@ -1519,16 +1511,15 @@ fn doctest_replace_unwrap_with_match() {
|
|||||||
check_doc_test(
|
check_doc_test(
|
||||||
"replace_unwrap_with_match",
|
"replace_unwrap_with_match",
|
||||||
r#####"
|
r#####"
|
||||||
enum Result<T, E> { Ok(T), Err(E) }
|
//- minicore: result
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: Result<i32, i32> = Result::Ok(92);
|
let x: Result<i32, i32> = Ok(92);
|
||||||
let y = x.$0unwrap();
|
let y = x.$0unwrap();
|
||||||
}
|
}
|
||||||
"#####,
|
"#####,
|
||||||
r#####"
|
r#####"
|
||||||
enum Result<T, E> { Ok(T), Err(E) }
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: Result<i32, i32> = Result::Ok(92);
|
let x: Result<i32, i32> = Ok(92);
|
||||||
let y = match x {
|
let y = match x {
|
||||||
Ok(it) => it,
|
Ok(it) => it,
|
||||||
$0_ => unreachable!(),
|
$0_ => unreachable!(),
|
||||||
|
Loading…
Reference in New Issue
Block a user