From b622fd7993cf0eb4eedcf805ecbdd7312afb5cdf Mon Sep 17 00:00:00 2001 From: Maik Klein Date: Fri, 9 Mar 2018 23:43:43 +0100 Subject: [PATCH] Add clone --- generator/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 90f6b56..ba33887 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -140,10 +140,20 @@ pub fn gen_load(feature: &vkxml::Feature, commands: &CommandMap) -> quote::Token } }) .collect(); + let names: Vec<_> = commands.iter().map(|cmd| cmd.command_ident()).collect(); + let names_left = &names; + let names_right = &names; quote!{ pub struct #ident { #(#function_pointers,)* } + impl ::std::clone::Clone for #ident { + pub fn clone(&self) -> Self { + #ident{ + #(#names_left: self.#names_right,)* + } + } + } } } let version = feature.version_string();