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

feat: allow generics for borsh storage key derive #930

Merged
merged 6 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update generic bounds for impl
  • Loading branch information
austinabell committed Sep 26, 2022
commit a074e2c4c8d2af29b532d4eb003a35622bbf63e3
2 changes: 1 addition & 1 deletion near-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub fn borsh_storage_key(item: TokenStream) -> TokenStream {
};
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
TokenStream::from(quote! {
impl #impl_generics near_sdk::__private::BorshIntoStorageKey for #name #ty_generics #where_clause {}
impl #impl_generics near_sdk::__private::BorshIntoStorageKey for #name #ty_generics #where_clause #name #ty_generics: ::near_sdk::borsh::BorshSerialize {}
})
}

Expand Down
4 changes: 2 additions & 2 deletions near-sdk/compilation_tests/borsh_storage_key_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use near_sdk::{near_bindgen, BorshStorageKey};
#[derive(BorshStorageKey, BorshSerialize)]
struct StorageKeyStruct<'a, T>
where
T: BorshSerialize + ?Sized,
T: ?Sized,
{
key: &'a T,
}

#[derive(BorshStorageKey, BorshSerialize)]
enum StorageKeyEnum<'a, T>
where
T: BorshSerialize + ?Sized,
T: ?Sized,
{
Accounts,
SubAccounts { account_id: &'a T },
Expand Down