@@ -1379,6 +1379,20 @@ where
13791379 }
13801380}
13811381
1382+ // For functions that accept no arguments. Implemented explicitly instead of via
1383+ // macro below to avoid unused warnings.
1384+ impl FromArgs for ( ) {
1385+ fn from_args < I > (
1386+ _vm : & mut VirtualMachine ,
1387+ _args : & mut iter:: Peekable < I > ,
1388+ ) -> Result < Self , ArgumentError >
1389+ where
1390+ I : Iterator < Item = PyArg > ,
1391+ {
1392+ Ok ( ( ) )
1393+ }
1394+ }
1395+
13821396// A tuple of types that each implement `FromArgs` represents a sequence of
13831397// arguments that can be bound and passed to a built-in function.
13841398//
@@ -1465,25 +1479,26 @@ impl IntoPyNativeFunc<PyFuncArgs, PyResult> for PyNativeFunc {
14651479//
14661480// Note that this could be done without a macro - it is simply to avoid repetition.
14671481macro_rules! into_py_native_func_tuple {
1468- ( $( ( $n: tt, $T: ident) ) ,+ ) => {
1469- impl <F , $( $T, ) + R > IntoPyNativeFunc <( $( $T, ) + ) , R > for F
1482+ ( $( ( $n: tt, $T: ident) ) ,* ) => {
1483+ impl <F , $( $T, ) * R > IntoPyNativeFunc <( $( $T, ) * ) , R > for F
14701484 where
1471- F : Fn ( $( $T, ) + & mut VirtualMachine ) -> R + ' static ,
1472- $( $T: FromArgs , ) +
1473- ( $( $T, ) + ) : FromArgs ,
1485+ F : Fn ( $( $T, ) * & mut VirtualMachine ) -> R + ' static ,
1486+ $( $T: FromArgs , ) *
1487+ ( $( $T, ) * ) : FromArgs ,
14741488 R : IntoPyObject ,
14751489 {
14761490 fn into_func( self ) -> PyNativeFunc {
14771491 Box :: new( move |vm, args| {
1478- let ( $( $n, ) + ) = args. bind:: <( $( $T, ) + ) >( vm) ?;
1492+ let ( $( $n, ) * ) = args. bind:: <( $( $T, ) * ) >( vm) ?;
14791493
1480- ( self ) ( $( $n, ) + vm) . into_pyobject( & vm. ctx)
1494+ ( self ) ( $( $n, ) * vm) . into_pyobject( & vm. ctx)
14811495 } )
14821496 }
14831497 }
14841498 } ;
14851499}
14861500
1501+ into_py_native_func_tuple ! ( ) ;
14871502into_py_native_func_tuple ! ( ( a, A ) ) ;
14881503into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) ) ;
14891504into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) ) ;
0 commit comments