blob: 375ac3715fc6b7f97d75729f0a99607ca52e69a2 [file] [log] [blame]
use std::borrow::Cow;
use std::pin::Pin;
use crate::prelude::*;
use crate::stream::{self, FromStream, IntoStream};
impl FromStream<char> for String {
#[inline]
fn from_stream<'a, S: IntoStream<Item = char> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
let stream = stream.into_stream();
Box::pin(async move {
let mut out = String::new();
stream::extend(&mut out, stream).await;
out
})
}
}
impl<'b> FromStream<&'b char> for String {
#[inline]
fn from_stream<'a, S: IntoStream<Item = &'b char> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
let stream = stream.into_stream();
Box::pin(async move {
let mut out = String::new();
stream::extend(&mut out, stream).await;
out
})
}
}
impl<'b> FromStream<&'b str> for String {
#[inline]
fn from_stream<'a, S: IntoStream<Item = &'b str> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
let stream = stream.into_stream();
Box::pin(async move {
let mut out = String::new();
stream::extend(&mut out, stream).await;
out
})
}
}
impl FromStream<String> for String {
#[inline]
fn from_stream<'a, S: IntoStream<Item = String> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
let stream = stream.into_stream();
Box::pin(async move {
let mut out = String::new();
stream::extend(&mut out, stream).await;
out
})
}
}
impl<'b> FromStream<Cow<'b, str>> for String {
#[inline]
fn from_stream<'a, S: IntoStream<Item = Cow<'b, str>> + 'a>(
stream: S,
) -> Pin<Box<dyn Future<Output = Self> + 'a>> {
let stream = stream.into_stream();
Box::pin(async move {
let mut out = String::new();
stream::extend(&mut out, stream).await;
out
})
}
}