From 604267088c9ef6afa021807b437dab22d72dfc99 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 16 Jun 2021 22:48:48 +0300 Subject: internal: add iterator to minicore --- crates/test_utils/src/minicore.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index e04ca58d2..011d460be 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs @@ -20,6 +20,7 @@ //! future: pin //! option: //! result: +//! iterator: option pub mod marker { // region:sized @@ -206,9 +207,38 @@ pub mod task { } // endregion:future +// region:iterator +pub mod iter { + mod traits { + mod iterator { + pub trait Iterator { + type Item; + #[lang = "next"] + fn next(&mut self) -> Option; + fn nth(&mut self, n: usize) -> Option { + loop {} + } + } + } + mod collect { + pub trait IntoIterator { + type Item; + type IntoIter: Iterator; + #[lang = "into_iter"] + fn into_iter(self) -> Self::IntoIter; + } + } + pub use self::collect::IntoIterator; + pub use self::iterator::Iterator; + } + pub use self::traits::{IntoIterator, Iterator}; +} +// endregion:iterator + pub mod prelude { pub mod v1 { pub use crate::{ + iter::{IntoIterator, Iterator}, // :iterator marker::Sized, // :sized ops::{Fn, FnMut, FnOnce}, // :fn option::Option::{self, None, Some}, // :option -- cgit v1.2.3 From ee7b649d445b9c33486f3b5c3bef29bdb28124bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 16 Jun 2021 22:54:57 +0300 Subject: internal: switch some tests to minicore --- crates/test_utils/src/minicore.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index 011d460be..a861ff09c 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs @@ -227,6 +227,13 @@ pub mod iter { #[lang = "into_iter"] fn into_iter(self) -> Self::IntoIter; } + impl IntoIterator for I { + type Item = I::Item; + type IntoIter = I; + fn into_iter(self) -> I { + self + } + } } pub use self::collect::IntoIterator; pub use self::iterator::Iterator; -- cgit v1.2.3 From 35772256f8ff3c52e469fc2bd388ad80ff8d79c7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 16 Jun 2021 23:27:04 +0300 Subject: internal: cleanup tests --- crates/test_utils/src/minicore.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs index a861ff09c..2f0da7fe5 100644 --- a/crates/test_utils/src/minicore.rs +++ b/crates/test_utils/src/minicore.rs @@ -209,8 +209,29 @@ pub mod task { // region:iterator pub mod iter { + mod adapters { + pub struct Take { + iter: I, + n: usize, + } + + impl Iterator for Take + where + I: Iterator, + { + type Item = ::Item; + + fn next(&mut self) -> Option<::Item> { + loop {} + } + } + } + pub use self::adapters::Take; + mod traits { mod iterator { + use super::super::Take; + pub trait Iterator { type Item; #[lang = "next"] @@ -218,8 +239,13 @@ pub mod iter { fn nth(&mut self, n: usize) -> Option { loop {} } + fn take(self, n: usize) -> crate::iter::Take { + loop {} + } } } + pub use self::iterator::Iterator; + mod collect { pub trait IntoIterator { type Item; @@ -236,7 +262,6 @@ pub mod iter { } } pub use self::collect::IntoIterator; - pub use self::iterator::Iterator; } pub use self::traits::{IntoIterator, Iterator}; } -- cgit v1.2.3