Remove explicit S type parameters (#5275)
* Remove explicit `S` type parameters This commit removes the explicit `S` type parameter on `Func::typed` and `Instance::get_typed_func`. Historical versions of Rust required that this be a type parameter but recent rustcs support a mixture of explicit type parameters and `impl Trait`. This removes, at callsites, a superfluous `, _` argument which otherwise never needs specification. * Fix mdbook examples
This commit is contained in:
@@ -117,7 +117,7 @@ fn bench_host_to_wasm<Params, Results>(
|
||||
// below.
|
||||
c.bench_function(&format!("host-to-wasm - typed - {}", name), |b| {
|
||||
let typed = instance
|
||||
.get_typed_func::<Params, Results, _>(&mut *store, name)
|
||||
.get_typed_func::<Params, Results>(&mut *store, name)
|
||||
.unwrap();
|
||||
b.iter(|| {
|
||||
let results = if is_async.use_async() {
|
||||
@@ -370,7 +370,7 @@ fn wasm_to_host(c: &mut Criterion) {
|
||||
) {
|
||||
group.bench_function(&format!("wasm-to-host - {} - nop", desc), |b| {
|
||||
let run = instance
|
||||
.get_typed_func::<u64, (), _>(&mut *store, "run-nop")
|
||||
.get_typed_func::<u64, ()>(&mut *store, "run-nop")
|
||||
.unwrap();
|
||||
b.iter_custom(|iters| {
|
||||
let start = Instant::now();
|
||||
@@ -386,7 +386,7 @@ fn wasm_to_host(c: &mut Criterion) {
|
||||
&format!("wasm-to-host - {} - nop-params-and-results", desc),
|
||||
|b| {
|
||||
let run = instance
|
||||
.get_typed_func::<u64, (), _>(&mut *store, "run-nop-params-and-results")
|
||||
.get_typed_func::<u64, ()>(&mut *store, "run-nop-params-and-results")
|
||||
.unwrap();
|
||||
b.iter_custom(|iters| {
|
||||
let start = Instant::now();
|
||||
|
||||
@@ -55,7 +55,7 @@ fn duration_of_call(engine: &Engine, module: &Module) -> Duration {
|
||||
let mut store = Store::new(engine, ());
|
||||
let inst = Instance::new(&mut store, module, &[]).expect("instantiate");
|
||||
let f = inst.get_func(&mut store, "f").expect("get f");
|
||||
let f = f.typed::<(), (), _>(&store).expect("type f");
|
||||
let f = f.typed::<(), ()>(&store).expect("type f");
|
||||
|
||||
let call = Instant::now();
|
||||
f.call(&mut store, ()).expect("call f");
|
||||
|
||||
@@ -38,9 +38,8 @@ fn bench_multi_threaded_traps(c: &mut Criterion) {
|
||||
move || {
|
||||
let mut store = Store::new(&engine, ());
|
||||
let instance = Instance::new(&mut store, &module, &[]).unwrap();
|
||||
let f = instance
|
||||
.get_typed_func::<(), (), _>(&mut store, "")
|
||||
.unwrap();
|
||||
let f =
|
||||
instance.get_typed_func::<(), ()>(&mut store, "").unwrap();
|
||||
|
||||
// Notify the parent thread that we are
|
||||
// doing background work now.
|
||||
@@ -67,9 +66,7 @@ fn bench_multi_threaded_traps(c: &mut Criterion) {
|
||||
|
||||
let mut store = Store::new(&engine, ());
|
||||
let instance = Instance::new(&mut store, &module, &[]).unwrap();
|
||||
let f = instance
|
||||
.get_typed_func::<(), (), _>(&mut store, "")
|
||||
.unwrap();
|
||||
let f = instance.get_typed_func::<(), ()>(&mut store, "").unwrap();
|
||||
|
||||
// Measure how long it takes to do `iters` worth of traps
|
||||
// while there is a bunch of background work going on.
|
||||
@@ -111,9 +108,7 @@ fn bench_many_modules_registered_traps(c: &mut Criterion) {
|
||||
b.iter_custom(|iters| {
|
||||
let mut store = Store::new(&engine, ());
|
||||
let instance = Instance::new(&mut store, modules.last().unwrap(), &[]).unwrap();
|
||||
let f = instance
|
||||
.get_typed_func::<(), (), _>(&mut store, "")
|
||||
.unwrap();
|
||||
let f = instance.get_typed_func::<(), ()>(&mut store, "").unwrap();
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
for _ in 0..iters {
|
||||
@@ -143,9 +138,7 @@ fn bench_many_stack_frames_traps(c: &mut Criterion) {
|
||||
b.iter_custom(|iters| {
|
||||
let mut store = Store::new(&engine, ());
|
||||
let instance = Instance::new(&mut store, &module, &[]).unwrap();
|
||||
let f = instance
|
||||
.get_typed_func::<(), (), _>(&mut store, "")
|
||||
.unwrap();
|
||||
let f = instance.get_typed_func::<(), ()>(&mut store, "").unwrap();
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
for _ in 0..iters {
|
||||
@@ -204,7 +197,7 @@ fn bench_host_wasm_frames_traps(c: &mut Criterion) {
|
||||
);
|
||||
let instance = Instance::new(&mut store, &module, &[host_func.into()]).unwrap();
|
||||
let f = instance
|
||||
.get_typed_func::<(i32,), (), _>(&mut store, "f")
|
||||
.get_typed_func::<(i32,), ()>(&mut store, "f")
|
||||
.unwrap();
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
Reference in New Issue
Block a user