Skip to content

Commit

Permalink
added From<StringQueue> for String
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLuq committed Jul 10, 2024
1 parent b25b67d commit 9115fcd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/queue/string_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ impl<'a> From<StringQueue<'a>> for StringData<'a> {
}
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "queue")))]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<'a> From<StringQueue<'a>> 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<StringData<'a>> for StringQueue<'a> {
fn from_iter<T: IntoIterator<Item = StringData<'a>>>(iter: T) -> Self {
let mut out = Self::new();
Expand Down

0 comments on commit 9115fcd

Please sign in to comment.