Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/Write mutable reference in serialize and deserialize_reader is unnecessary #141

Closed
billythedummy opened this issue Dec 10, 2023 · 1 comment

Comments

@billythedummy
Copy link

Currently, the required method for BorshDeserialize has the following signature:

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self>;

However, it can be changed to just:

fn deserialize_reader<R: Read>(reader: R) -> Result<Self>;

because Read has a blanket impl for mut references: https://docs.rs/borsh/latest/borsh/io/trait.Read.html#impl-Read-for-%26mut+R

Similarly, BorshSerialize can be changed from

fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>;

to

fn serialize<W: Write>(&self, writer: W) -> Result<()>;

because Write has a blanket impl for mut references: https://docs.rs/borsh/latest/borsh/io/trait.Write.html#impl-Write-for-%26mut+W

This will be a breaking change

@billythedummy
Copy link
Author

billythedummy commented Dec 10, 2023

wrong repo, sorry. Moved to: near/borsh-rs#270

@billythedummy billythedummy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant