svd2rust icon indicating copy to clipboard operation
svd2rust copied to clipboard

Add try_from for enum variants

Open Sh3Rm4n opened this issue 6 years ago • 1 comments

As From<enumVariant> for u8 is implemented in https://github.com/rust-embedded/svd2rust/pull/374.

What do you think about implementing TryFrom<u8> for enumVariant?

It could look something like this, in the generated code.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b703f510723d792edcd2776942cc02c7

Sh3Rm4n avatar Dec 27 '19 18:12 Sh3Rm4n

Not sure is this really required, but:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2134ed8c3cfe52076f7d6220a5f093a1

burrbull avatar Dec 28 '19 06:12 burrbull