mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-14 12:35:02 +01:00
worst error message ever
This commit is contained in:
parent
39b121e064
commit
962725e0bb
3 changed files with 133 additions and 6 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "futures-rs"]
|
||||
path = futures-rs
|
||||
url = git@github.com:rust-lang/futures-rs.git
|
||||
1
futures-rs
Submodule
1
futures-rs
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 86f0626e8b4d4484c381a37a492b2fff28dfaa92
|
||||
135
src/main.rs
135
src/main.rs
|
|
@ -1,14 +1,17 @@
|
|||
use futures::{stream, Future, StreamExt};
|
||||
use std::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures::{stream, StreamExt};
|
||||
|
||||
pub struct JoinHandle<T>(T);
|
||||
|
||||
impl<T> Future for JoinHandle<T> {
|
||||
type Output = Result<T, ()>;
|
||||
|
||||
fn poll(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,8 +20,128 @@ pub fn spawn<T: Future>(future: T) -> JoinHandle<T::Output> {
|
|||
loop {}
|
||||
}
|
||||
|
||||
pub trait Stream {
|
||||
/// Values yielded by the stream.
|
||||
type Item;
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(0, None)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Iter<I> {
|
||||
iter: I,
|
||||
}
|
||||
|
||||
impl<I> Unpin for Iter<I> {}
|
||||
|
||||
pub(crate) fn assert_stream<T, S>(stream: S) -> S
|
||||
where
|
||||
S: Stream<Item = T>,
|
||||
{
|
||||
stream
|
||||
}
|
||||
|
||||
pub fn iter<I>(i: I) -> Iter<I::IntoIter>
|
||||
where
|
||||
I: IntoIterator,
|
||||
{
|
||||
assert_stream::<I::Item, _>(Iter {
|
||||
iter: i.into_iter(),
|
||||
})
|
||||
}
|
||||
|
||||
impl<I> Stream for Iter<I>
|
||||
where
|
||||
I: Iterator,
|
||||
{
|
||||
type Item = I::Item;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<I::Item>> {
|
||||
Poll::Ready(self.iter.next())
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
self.iter.size_hint()
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Stream> Stream for &S {
|
||||
type Item = S::Item;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
impl<S: Stream> Stream for &mut S {
|
||||
type Item = S::Item;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
trait UwuStream: Stream {
|
||||
fn map<T, F>(self, f: F) -> Map<Self, F>
|
||||
where
|
||||
F: FnMut(Self::Item) -> T,
|
||||
Self: Sized,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
fn buffer_unordered(self, n: impl Into<Option<usize>>) -> BufferUnordered<Self>
|
||||
where
|
||||
Self::Item: Future,
|
||||
Self: Sized,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Stream> UwuStream for S {}
|
||||
pub struct Map<St, F> {
|
||||
stream: St,
|
||||
f: F,
|
||||
}
|
||||
impl<St, F> Stream for Map<St, F>
|
||||
where
|
||||
St: Stream,
|
||||
F: FnMut(St::Item),
|
||||
{
|
||||
type Item = F::Output;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
self.stream.size_hint()
|
||||
}
|
||||
}
|
||||
pub struct BufferUnordered<St>
|
||||
where
|
||||
St: Stream,
|
||||
{
|
||||
uwu: St,
|
||||
}
|
||||
|
||||
impl<St> Stream for BufferUnordered<St>
|
||||
where
|
||||
St: Stream,
|
||||
St::Item: Future,
|
||||
{
|
||||
type Item = <St::Item as Future>::Output;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
let bodies = stream::iter([])
|
||||
let bodies = iter([])
|
||||
.map(|url: String| spawn(async { Result::Ok(url) }))
|
||||
.buffer_unordered(0);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue