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:
Caio
2020-12-09 20:21:03 -03:00
committed by GitHub
parent 22f640be56
commit 6dccb480f7
+14
View File
@@ -594,3 +594,17 @@ where
Ok(v) 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)
}
}