Commit 9b82635
Merge #557
557: Add impl for TryFromSliceError r=justahero a=newAM
This implements `defmt::Format` for [`TryFromSliceError`](https://doc.rust-lang.org/stable/core/array/struct.TryFromSliceError.html) which enables code like this:
```rs
use core::convert::TryInto;
let foo: [u8; 5] = [0, 1, 2, 3, 4];
let bar: u32 = u32::from_be_bytes(defmt::unwrap!(foo[1..2].try_into()));
```
When it fails it looks like this:
```text
ERROR panicked at 'unwrap failed: foo [1 .. 2].try_into()'
error: `TryFromSliceError(())`
```
Which is similar to what it looks like on `std` targets with `.unwrap()`
```text
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TryFromIntError(())', src/main.rs:5:35
```
Co-authored-by: Alex Martens <alexmgit@protonmail.com>2 files changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
0 commit comments