Impl TryFrom<fmt::Arguments<'a>> for ArrayString
Shortcut for ``` use fmt::Write; let mut v = Self::new(); v.write_fmt(f).map_err(|e| CapacityError::new(e))?; ```
This commit is contained in:
@@ -594,3 +594,17 @@ where
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, A> TryFrom<fmt::Arguments<'a>> for ArrayString<A>
|
||||
where
|
||||
A: Array<Item = u8> + Copy
|
||||
{
|
||||
type Error = CapacityError<fmt::Error>;
|
||||
|
||||
fn try_from(f: fmt::Arguments<'a>) -> Result<Self, Self::Error> {
|
||||
use fmt::Write;
|
||||
let mut v = Self::new();
|
||||
v.write_fmt(f).map_err(|e| CapacityError::new(e))?;
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user