use opengl_registry::command::Command; use proc_macro2::TokenStream; use quote::{format_ident, quote}; pub fn create_load_with_function(commands: &[Command]) -> TokenStream { let command_assignments = commands.iter().map(|command| { let command_name = format_ident!("{}", command.prototype().name()); let command_name_str = command.prototype().name(); quote! { functions::#command_name = get_proc_addr(#command_name_str); } }); quote! { /// Loads OpenGL function pointers using the given function address retriever function. pub fn load_with(get_proc_addr: GetProcAddrFn) where GetProcAddrFn: Fn(&str) -> unsafe extern "C" fn(), { unsafe { #(#command_assignments)* } } } }