use std::fmt;
use core::fmt::Formatter;
use super::MicroStr;
impl<const CAP: usize> fmt::Debug for MicroStr<CAP> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "MicroStr<{}>{{\"{}\"}}", CAP, self.as_str())
}
}
impl<const CAP: usize> fmt::Display for MicroStr<CAP> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl<const CAP: usize> From<String> for MicroStr<CAP> {
fn from(value: String) -> Self {
match Self::from_str(&value) {
Ok(s) => {s},
Err((s, _)) => {s}
}
}
}
impl<const CAP: usize> From<MicroStr<CAP>> for String {
fn from(value: MicroStr<CAP>) -> Self {
let mut result = String::with_capacity(CAP);
result.push_str(&value);
result
}
}