You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be nice if plugins were available from rust not just python. I think the simplest way would be to have the polars_expr macro also emit a pub fn version of the function. It'd fall short if there were kwarg structs that aren't also public but that's a lot easier for plugin authors to patch for interoperability. ChatGPT suggested this but I don't know enough about macros to tell if it's good enough to put in a PR or even if that's really all it would take.
#[proc_macro_attribute]pubfnpolars_expr(attr:TokenStream,input:TokenStream) -> TokenStream{let ast = parse_macro_input!(input as syn::ItemFn);let fn_name = &ast.sig.ident;let options = parse_macro_input!(attr as attr::ExprsFunctionOptions);let expanded_field_fn = ifletSome(fn_name) = options.output_type_fn{create_field_function(fn_name,&fn_name,false)}elseifletSome(fn_name) = options.output_type_fn_kwargs{create_field_function(fn_name,&fn_name,true)}elseifletSome(dtype) = options.output_dtype{create_field_function_from_with_dtype(fn_name, dtype)}else{panic!("didn't understand polars_expr attribute")};let expanded_expr = create_expression_function(&ast);// Modify the function to ensure it's publicletmut modified_ast = ast.clone();
modified_ast.vis = syn::Visibility::Public(syn::token::Pub{span: proc_macro2::Span::call_site()});let expanded = quote!{
#expanded_field_fn
#expanded_expr
// Keep the original function as `pub fn`
#modified_ast
};TokenStream::from(expanded)}
The text was updated successfully, but these errors were encountered:
deanm0000
changed the title
make the polars_expr macro create a pub fn version of the function
Interoperable plugins, ie make plugin functions public so they can be used by rust, not just python.
Feb 20, 2025
It'd be nice if plugins were available from rust not just python. I think the simplest way would be to have the polars_expr macro also emit a pub fn version of the function. It'd fall short if there were kwarg structs that aren't also public but that's a lot easier for plugin authors to patch for interoperability. ChatGPT suggested this but I don't know enough about macros to tell if it's good enough to put in a PR or even if that's really all it would take.
The text was updated successfully, but these errors were encountered: