makepad/libs/relax/compiler/tests/n01_closure_slot_abi.rs
Admin b22a714840 makepad run: the Rust JIT (libs/relax) and makepad-remote
The JIT that runs makepad apps from source: lexer, front end, type checker,
lazy borrow checker (Gandalf; `--check-first` opts in), codegen, session and
warm/cold caches keyed by compiler stamp, provided crates bound late,
startup images, live patching. User-facing name is `makepad run` (binary
`makepad`, MAKEPAD_RUN_* env, ~/.makepad-run); libs/relax stays the internal
library name. `makepad check` reports rustc-style diagnostics with rustc
error codes and checks a whole workspace (`--workspace`). Runs on macOS,
Linux, Windows and Android. makepad-remote: one tool schema for apps and the
WM (app/1): grabs, captures, traces, frame profiles and tweaks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 12:26:21 +02:00

18 lines
550 B
Rust

fn through_dyn(f: &dyn Fn(u64) -> u64, x: u64) -> u64 { f(x) }
#[test]
fn capture_free_closure_as_pointer_and_dyn_fn() {
let f = |x: u64| x + 17;
let pointer: fn(u64) -> u64 = f;
assert_eq!(pointer(5), 22);
assert_eq!(through_dyn(&f, 5), 22);
}
#[test]
fn capture_free_closure_through_generic_fn_and_fnmut() {
fn call<F: Fn(u64) -> u64>(f: &F) -> u64 { f(5) }
fn call_mut<F: FnMut(u64) -> u64>(f: &mut F) -> u64 { f(5) }
let mut f = |x: u64| x + 17;
assert_eq!(call(&f), 22);
assert_eq!(call_mut(&mut f), 22);
}