Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions rkyv/src/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ mod core_tests {
#[derive(
Clone, Debug, Default, Archive, Deserialize, Portable, Serialize,
)]
// Self should be handled specifically (we can't `impl ... for Self`)
#[rkyv(crate, as = Self)]
#[repr(C)]
struct Example {
Expand Down
13 changes: 11 additions & 2 deletions rkyv_derive/src/deserialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::{Span, TokenStream};
use quote::quote;
use quote::{format_ident, quote};
use syn::{
parse_quote, punctuated::Punctuated, spanned::Spanned, Data, DeriveInput,
Error, Fields, Generics, Ident, Index, Path, WhereClause,
Expand Down Expand Up @@ -103,11 +103,20 @@ fn derive_deserialize_impl(
Ident::new("Self", Span::call_site()),
name,
)?;
let base_name = crate::util::strip_raw(&name);
let archived_name = attributes
.archived
.clone()
.unwrap_or_else(|| format_ident!("Archived{}", base_name));
let archived_type = attributes
.as_type
.clone()
.unwrap_or_else(|| parse_quote! { #archived_name #ty_generics });

Ok(quote! {
#[automatically_derived]
impl #impl_generics #rkyv_path::Deserialize<#name #ty_generics, __D>
for #rkyv_path::Archived<#name #ty_generics>
for #archived_type
#deserialize_where
{
fn deserialize(
Expand Down