mod sealed {
pub trait Sealed {}
#[cfg(all(not(feature = "std"), feature = "alloc"))]
use alloc::string::String;
#[cfg(any(feature = "std", feature = "alloc"))]
impl Sealed for String {}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub trait StringBarfExt: sealed::Sealed {
fn string<S: AsRef<str>>(&mut self, s: S);
fn bytes<B: AsRef<[u8]>>(&mut self, b: B) -> Result<(), core::str::Utf8Error>;
}
#[cfg(any(feature = "std", feature = "alloc"))]
impl StringBarfExt for String {
#[inline]
fn string<S: AsRef<str>>(&mut self, s: S) {
self.push_str(s.as_ref());
}
fn bytes<B: AsRef<[u8]>>(&mut self, b: B) -> Result<(), core::str::Utf8Error> {
self.push_str(core::str::from_utf8(b.as_ref())?);
Ok(())
}
}