Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impl for TryFromIntError #556

Merged
merged 1 commit into from
Aug 9, 2021
Merged

Add impl for TryFromIntError #556

merged 1 commit into from
Aug 9, 2021

Conversation

newAM
Copy link
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
Contributor

Thanks!

bors r+

@bors
Copy link
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