File tree 3 files changed +12
-0
lines changed
3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ pub(crate) fn expand_install_with(
155
155
}
156
156
157
157
installers. extend ( attr. protocols . iter ( ) . map ( |protocol| protocol. expand ( ) ) ) ;
158
+ installers. extend ( attr. functions . iter ( ) . map ( |function| quote_spanned ! { function. span( ) =>
159
+ module. function_meta( #function) ?;
160
+ } ) ) ;
158
161
159
162
if let Some ( install_with) = & attr. install_with {
160
163
installers. push ( quote_spanned ! { input. span( ) =>
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ pub(crate) struct TypeAttr {
74
74
pub ( crate ) item : Option < syn:: Path > ,
75
75
/// Protocols to "derive"
76
76
pub ( crate ) protocols : Vec < TypeProtocol > ,
77
+ /// Assosiated functions
78
+ pub ( crate ) functions : Vec < syn:: Path > ,
77
79
/// Parsed documentation.
78
80
pub ( crate ) docs : Vec < syn:: Expr > ,
79
81
}
@@ -503,6 +505,12 @@ impl Context {
503
505
syn:: parenthesized!( protocols in meta. input) ;
504
506
attr. protocols
505
507
. extend ( protocols. parse_terminated ( TypeProtocol :: parse, Token ! [ , ] ) ?) ;
508
+ } else if meta. path == FUNCTIONS {
509
+ // Parse `#[rune(functions(<function>,*))]`
510
+ let functions;
511
+ syn:: parenthesized!( functions in meta. input) ;
512
+ attr. functions
513
+ . extend ( functions. parse_terminated ( syn:: Path :: parse, Token ! [ , ] ) ?) ;
506
514
} else {
507
515
return Err ( syn:: Error :: new_spanned (
508
516
& meta. path ,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ pub const ITEM: Symbol = Symbol("item");
20
20
pub const MODULE : Symbol = Symbol ( "module" ) ;
21
21
pub const INSTALL_WITH : Symbol = Symbol ( "install_with" ) ;
22
22
pub const PROTOCOLS : Symbol = Symbol ( "protocols" ) ;
23
+ pub const FUNCTIONS : Symbol = Symbol ( "functions" ) ;
23
24
24
25
pub const CONSTRUCTOR : Symbol = Symbol ( "constructor" ) ;
25
26
pub const GET : Symbol = Symbol ( "get" ) ;
You can’t perform that action at this time.
0 commit comments