mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
internal: add iterator to minicore
This commit is contained in:
parent
7ba5482a04
commit
604267088c
@ -418,48 +418,17 @@ fn issue_2705() {
|
||||
fn issue_2683_chars_impl() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:std
|
||||
//- minicore: iterator
|
||||
pub struct Chars<'a> {}
|
||||
impl<'a> Iterator for Chars<'a> {
|
||||
type Item = char;
|
||||
fn next(&mut self) -> Option<char> {}
|
||||
}
|
||||
|
||||
fn test() {
|
||||
let chars: std::str::Chars<'_>;
|
||||
let chars: Chars<'_>;
|
||||
(chars.next(), chars.nth(1));
|
||||
} //^ (Option<char>, Option<char>)
|
||||
|
||||
//- /std.rs crate:std
|
||||
#[prelude_import]
|
||||
use self::prelude::rust_2018::*;
|
||||
pub mod prelude {
|
||||
pub mod rust_2018 {
|
||||
pub use crate::iter::Iterator;
|
||||
pub use crate::option::Option;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod iter {
|
||||
pub use self::traits::Iterator;
|
||||
pub mod traits {
|
||||
pub use self::iterator::Iterator;
|
||||
|
||||
pub mod iterator {
|
||||
pub trait Iterator {
|
||||
type Item;
|
||||
fn next(&mut self) -> Option<Self::Item>;
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod option {
|
||||
pub enum Option<T> {}
|
||||
}
|
||||
|
||||
pub mod str {
|
||||
pub struct Chars<'a> {}
|
||||
impl<'a> Iterator for Chars<'a> {
|
||||
type Item = char;
|
||||
fn next(&mut self) -> Option<char> {}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
@ -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<Self::Item>;
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
}
|
||||
mod collect {
|
||||
pub trait IntoIterator {
|
||||
type Item;
|
||||
type IntoIter: Iterator<Item = Self::Item>;
|
||||
#[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
|
||||
|
Loading…
Reference in New Issue
Block a user