Skip to content

Add impl for TryFromIntError#556

Merged
bors[bot] merged 1 commit intoknurling-rs:mainfrom
newAM:main
Aug 9, 2021
Merged

Add impl for TryFromIntError#556
bors[bot] merged 1 commit intoknurling-rs:mainfrom
newAM:main

Conversation

@newAM
Copy link
Copy Markdown
Member

@newAM newAM commented Aug 6, 2021

This implements defmt::Format for TryFromIntError which enables code like this:

use core::convert::{TryFrom, TryInto};

let foo: u64 = u64::MAX;
let bar: u32 = defmt::unwrap!(foo.try_into());
let eggs: u32 = defmt::unwrap!(u32::try_from(foo));

When it fails it looks like this:

ERROR panicked at 'unwrap failed: foo.try_into()'
error: `TryFromIntError(())`

Which is similar to what it looks like on std targets with .unwrap()

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TryFromIntError(())', src/main.rs:5:35

@jonas-schievink
Copy link
Copy Markdown
Contributor

Thanks!

bors r+

@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Aug 9, 2021

Build succeeded:

@bors bors Bot merged commit f5abeac into knurling-rs:main Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants