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

refactor!: borsh_init to borsh(init). #187

Merged
merged 23 commits into from
Aug 10, 2023
Merged

Conversation

iho
Copy link
Contributor

@iho iho commented Aug 8, 2023

Resolves #186 and is part of #51

Migration guide: replace all #[borsh_init(init_method_name)] to #[borsh(init=init_method_name)]

@iho iho changed the title refactor!: borsh_init to borsh(init) refactor!: borsh_init to borsh(init). Resolves #186 and part of #51 Aug 9, 2023
@dj8yfo dj8yfo changed the title refactor!: borsh_init to borsh(init). Resolves #186 and part of #51 refactor!: borsh_init to borsh(init). Aug 9, 2023
@iho iho marked this pull request as ready for review August 9, 2023 08:04
@iho iho requested review from frol and dj8yfo as code owners August 9, 2023 08:04
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good to me.

I feel we need to write a migration guide for this release for all the breaking changes (I would use CHANGELOG file for this purpose, but I would add a dedicated section there)

borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh/tests/test_simple_structs.rs Show resolved Hide resolved
borsh/tests/test_init_in_deserialize.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/mod.rs Outdated Show resolved Hide resolved
Comment on lines 8 to 10
let attr = derive_input.attrs.iter().find(|attr| attr.path() == SKIP);

if attr.is_some() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, you can use any instead of find + is_some:

Suggested change
let attr = derive_input.attrs.iter().find(|attr| attr.path() == SKIP);
if attr.is_some() {
if derive_input.attrs.iter().any(|attr| attr.path() == SKIP) {

This might, however make the code split across several lines and actually make it harder to read

borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/lib.rs Outdated Show resolved Hide resolved
@iho iho marked this pull request as draft August 10, 2023 17:36
@iho iho marked this pull request as ready for review August 10, 2023 17:37
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
borsh-derive/src/internals/attributes/item/mod.rs Outdated Show resolved Hide resolved
@dj8yfo dj8yfo merged commit cbf58d9 into near:master Aug 10, 2023
7 checks passed
This was referenced Aug 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

Successfully merging this pull request may close these issues.

Add a test or two on #[borsh_init(init)] logic
3 participants