near / borsh-rs

Rust implementation of Binary Object Representation Serializer for Hashing
https://borsh.io/
Apache License 2.0
299 stars 65 forks source link

Include discriminant number in `BorshSchema::Enum::variants` #230

Closed mina86 closed 11 months ago

mina86 commented 11 months ago

Since variants of an enum may use arbitrary tag (rather than sequential numbers), those tags should be included in the schema information.

    Enum {
        tag_width: u8,
        variants: Vec<(VariantName, Declaration)>,
    },

->

    Enum {  // `i64` added to variants tuple
        tag_width: u8,
        variants: Vec<(i64, VariantName, Declaration)>,
    },

(rust allows isize for discriminant numbers)