@@ -1413,8 +1413,8 @@ impl Lua {
1413
1413
let protect = !self . unlikely_memory_error ( ) ;
1414
1414
push_table ( state, 0 , lower_bound, protect) ?;
1415
1415
for ( k, v) in iter {
1416
- self . push_value ( k . into_lua ( self ) ? ) ?;
1417
- self . push_value ( v . into_lua ( self ) ? ) ?;
1416
+ self . push ( k ) ?;
1417
+ self . push ( v ) ?;
1418
1418
if protect {
1419
1419
protect_lua ! ( state, 3 , 1 , fn ( state) ffi:: lua_rawset( state, -3 ) ) ?;
1420
1420
} else {
@@ -1442,7 +1442,7 @@ impl Lua {
1442
1442
let protect = !self . unlikely_memory_error ( ) ;
1443
1443
push_table ( state, lower_bound, 0 , protect) ?;
1444
1444
for ( i, v) in iter. enumerate ( ) {
1445
- self . push_value ( v . into_lua ( self ) ? ) ?;
1445
+ self . push ( v ) ?;
1446
1446
if protect {
1447
1447
protect_lua ! ( state, 2 , 1 , |state| {
1448
1448
ffi:: lua_rawseti( state, -2 , ( i + 1 ) as Integer ) ;
@@ -1977,12 +1977,11 @@ impl Lua {
1977
1977
T : IntoLua < ' lua > ,
1978
1978
{
1979
1979
let state = self . state ( ) ;
1980
- let t = t. into_lua ( self ) ?;
1981
1980
unsafe {
1982
1981
let _sg = StackGuard :: new ( state) ;
1983
1982
check_stack ( state, 5 ) ?;
1984
1983
1985
- self . push_value ( t) ?;
1984
+ self . push ( t) ?;
1986
1985
rawset_field ( state, ffi:: LUA_REGISTRYINDEX , name)
1987
1986
}
1988
1987
}
@@ -2269,6 +2268,12 @@ impl Lua {
2269
2268
extra. app_data . remove ( )
2270
2269
}
2271
2270
2271
+ #[ doc( hidden) ]
2272
+ #[ inline( always) ]
2273
+ pub unsafe fn push < ' lua > ( & ' lua self , value : impl IntoLua < ' lua > ) -> Result < ( ) > {
2274
+ value. push_into_stack ( self )
2275
+ }
2276
+
2272
2277
/// Pushes a value onto the Lua stack.
2273
2278
///
2274
2279
/// Uses 2 stack spaces, does not call checkstack.
@@ -2643,12 +2648,12 @@ impl Lua {
2643
2648
let metatable_nrec = metatable_nrec + registry. async_meta_methods . len ( ) ;
2644
2649
push_table ( state, 0 , metatable_nrec, true ) ?;
2645
2650
for ( k, m) in registry. meta_methods {
2646
- self . push_value ( Value :: Function ( self . create_callback ( m) ?) ) ?;
2651
+ self . push ( self . create_callback ( m) ?) ?;
2647
2652
rawset_field ( state, -2 , MetaMethod :: validate ( & k) ?) ?;
2648
2653
}
2649
2654
#[ cfg( feature = "async" ) ]
2650
2655
for ( k, m) in registry. async_meta_methods {
2651
- self . push_value ( Value :: Function ( self . create_async_callback ( m) ?) ) ?;
2656
+ self . push ( self . create_async_callback ( m) ?) ?;
2652
2657
rawset_field ( state, -2 , MetaMethod :: validate ( & k) ?) ?;
2653
2658
}
2654
2659
let mut has_name = false ;
@@ -2699,7 +2704,7 @@ impl Lua {
2699
2704
if field_getters_nrec > 0 {
2700
2705
push_table ( state, 0 , field_getters_nrec, true ) ?;
2701
2706
for ( k, m) in registry. field_getters {
2702
- self . push_value ( Value :: Function ( self . create_callback ( m) ?) ) ?;
2707
+ self . push ( self . create_callback ( m) ?) ?;
2703
2708
rawset_field ( state, -2 , & k) ?;
2704
2709
}
2705
2710
field_getters_index = Some ( ffi:: lua_absindex ( state, -1 ) ) ;
@@ -2711,7 +2716,7 @@ impl Lua {
2711
2716
if field_setters_nrec > 0 {
2712
2717
push_table ( state, 0 , field_setters_nrec, true ) ?;
2713
2718
for ( k, m) in registry. field_setters {
2714
- self . push_value ( Value :: Function ( self . create_callback ( m) ?) ) ?;
2719
+ self . push ( self . create_callback ( m) ?) ?;
2715
2720
rawset_field ( state, -2 , & k) ?;
2716
2721
}
2717
2722
field_setters_index = Some ( ffi:: lua_absindex ( state, -1 ) ) ;
@@ -2734,12 +2739,12 @@ impl Lua {
2734
2739
}
2735
2740
}
2736
2741
for ( k, m) in registry. methods {
2737
- self . push_value ( Value :: Function ( self . create_callback ( m) ?) ) ?;
2742
+ self . push ( self . create_callback ( m) ?) ?;
2738
2743
rawset_field ( state, -2 , & k) ?;
2739
2744
}
2740
2745
#[ cfg( feature = "async" ) ]
2741
2746
for ( k, m) in registry. async_methods {
2742
- self . push_value ( Value :: Function ( self . create_async_callback ( m) ?) ) ?;
2747
+ self . push ( self . create_async_callback ( m) ?) ?;
2743
2748
rawset_field ( state, -2 , & k) ?;
2744
2749
}
2745
2750
match index_type {
@@ -2990,7 +2995,7 @@ impl Lua {
2990
2995
nresults => {
2991
2996
let results = MultiValue :: from_stack_multi ( nresults, lua) ?;
2992
2997
ffi:: lua_pushinteger ( state, nresults as _ ) ;
2993
- lua. push_value ( Value :: Table ( lua. create_sequence_from ( results) ?) ) ?;
2998
+ lua. push ( lua. create_sequence_from ( results) ?) ?;
2994
2999
Ok ( 2 )
2995
3000
}
2996
3001
}
0 commit comments