You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I understand the current API correctly we can do conversion of bitfield fields via specifying into T in the field specification. What I'm currently missing is a way to use try_into instead of into.
With my use-case it would look like this (in our normal case I'd use num_enum, removed that for simplicity):
#[repr(u8)]pubenumUidSize{Single = 0,Double = 1,Triple = 2,}implTryFrom<u8>forUidSize{typeError = ();fntry_from(value:u8) -> Result<Self,Self::Error>{match value {0 => Ok(UidSize::Single),1 => Ok(UidSize::Double),2 => Ok(UidSize::Triple),
_ => Err(()),}}}bitfield!{pubstructAtqa(u16);implDebug;// The fields default to u16pub bitframe_anticoll, set_bitframe_anticoll:4,0;pubu8, from try_into UidSize, uid_size, set_uid_size:7,6;}
and the uid_size getter would have to have a Result<UidSize, ()> return value.
Is this currently possible and I overlooked it? Otherwise it would be cool if this could be added...
The text was updated successfully, but these errors were encountered:
If I understand the current API correctly we can do conversion of bitfield fields via specifying
into T
in the field specification. What I'm currently missing is a way to usetry_into
instead ofinto
.With my use-case it would look like this (in our normal case I'd use
num_enum
, removed that for simplicity):and the
uid_size
getter would have to have aResult<UidSize, ()>
return value.Is this currently possible and I overlooked it? Otherwise it would be cool if this could be added...
The text was updated successfully, but these errors were encountered: