near / borsh

Binary Object Representation Serializer for Hashing
https://borsh.io/
487 stars 41 forks source link

Implement serialization for std::borrow::Cow #74

Closed frol closed 4 years ago

frol commented 4 years ago

How hard would it be to implement Cow support?

When you deserialize, you just always use the Owned variant, otherwise, you only need as_ref() to read the data.

/cc @nearmax

evgenykuzyakov commented 4 years ago

Can you give an example?

frol commented 4 years ago
#[derive(
    BorshSerialize,
    BorshDeserialize,
)]
pub struct AccountId<'a>(std::borrow::Cow<'a, str>);
evgenykuzyakov commented 4 years ago

Well, it shouldn't be an issue I guess

frol commented 4 years ago

Cool thanks! I will take a look from here.