@@ -3,7 +3,7 @@ use magnus::{exception::arg_error, Error, ExceptionClass, Value};
33use static_assertions:: assert_eq_size;
44use wasmtime:: { FuncType , ValType } ;
55
6- #[ derive( Debug , Copy , Clone ) ]
6+ #[ derive( Debug , Clone ) ]
77#[ repr( C ) ]
88struct Param {
99 val : Value ,
@@ -19,17 +19,19 @@ impl Param {
1919 Self { index, ty, val }
2020 }
2121
22- fn to_wasmtime_val ( self ) -> Result < wasmtime:: Val , Error > {
23- self . val . to_wasm_val ( self . ty ) . map_err ( |error| match error {
24- Error :: Error ( class, msg) => {
25- Error :: new ( class, format ! ( "{} (param at index {})" , msg, self . index) )
26- }
27- Error :: Exception ( exception) => Error :: new (
28- ExceptionClass :: from_value ( exception. class ( ) . into ( ) ) . unwrap_or_else ( arg_error) ,
29- format ! ( "{} (param at index {})" , exception, self . index) ,
30- ) ,
31- _ => error,
32- } )
22+ fn to_wasmtime_val ( & self ) -> Result < wasmtime:: Val , Error > {
23+ self . val
24+ . to_wasm_val ( self . ty . clone ( ) )
25+ . map_err ( |error| match error {
26+ Error :: Error ( class, msg) => {
27+ Error :: new ( class, format ! ( "{} (param at index {})" , msg, self . index) )
28+ }
29+ Error :: Exception ( exception) => Error :: new (
30+ ExceptionClass :: from_value ( exception. class ( ) . into ( ) ) . unwrap_or_else ( arg_error) ,
31+ format ! ( "{} (param at index {})" , exception, self . index) ,
32+ ) ,
33+ _ => error,
34+ } )
3335 }
3436}
3537
0 commit comments