From 9115fcd3ccbf64d87e7cfee8c1435b14ca7d5be8 Mon Sep 17 00:00:00 2001 From: TimLuq Date: Wed, 10 Jul 2024 12:40:09 +0200 Subject: [PATCH] added `From for String` --- src/queue/string_queue.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/queue/string_queue.rs b/src/queue/string_queue.rs index 61d40df..a200190 100644 --- a/src/queue/string_queue.rs +++ b/src/queue/string_queue.rs @@ -346,6 +346,20 @@ impl<'a> From> for StringData<'a> { } } +#[cfg(feature = "alloc")] +#[cfg_attr(docsrs, doc(cfg(feature = "queue")))] +#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] +impl<'a> From> for alloc::string::String { + #[inline] + fn from(data: StringQueue<'a>) -> Self { + let mut out = alloc::string::String::with_capacity(data.len()); + for c in data.chunks() { + out.push_str(c.as_str()); + } + out + } +} + impl<'a> FromIterator> for StringQueue<'a> { fn from_iter>>(iter: T) -> Self { let mut out = Self::new();