Open
Description
whe the discriminant doesn't fit u8 the derivation is wrong (more precisely: unexpected)
#[derive(Encode, Decode)]
#[repr(u32)]
enum ABC {
D = 3u32,
}
#[repr(u32)]
enum ABC { D = 3u32, }
const _: () =
{
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate parity_scale_codec as _parity_scale_codec;
impl _parity_scale_codec::Encode for ABC {
fn encode_to<__CodecOutputEdqy: _parity_scale_codec::Output +
?Sized>(&self,
__codec_dest_edqy: &mut __CodecOutputEdqy) {
match *self {
ABC::D => {
__codec_dest_edqy.push_byte(3u32 as
::core::primitive::u8);
}
_ => (),
}
}
}
impl _parity_scale_codec::EncodeLike for ABC { }
};
const _: () =
{
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate parity_scale_codec as _parity_scale_codec;
impl _parity_scale_codec::Decode for ABC {
fn decode<__CodecInputEdqy: _parity_scale_codec::Input>(__codec_input_edqy:
&mut __CodecInputEdqy)
-> ::core::result::Result<Self, _parity_scale_codec::Error> {
match __codec_input_edqy.read_byte().map_err(|e|
e.chain("Could not decode `ABC`, failed to read variant byte"))?
{
__codec_x_edqy if
__codec_x_edqy == 3u32 as ::core::primitive::u8 => {
::core::result::Result::Ok(ABC::D)
}
_ =>
::core::result::Result::Err("Could not decode `ABC`, variant doesn\'t exist".into()),
}
}
}
};
I think we can use From::from
instead of as
maybe but it is probably a breaking change.
Metadata
Metadata
Assignees
Labels
No labels