Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49389c4

Browse files
committed
WrapFunction::coverage callback toRefCell (Luau)
1 parent13dc2b5 commit49389c4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

‎src/function.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl Function {
434434
/// [`Compiler::set_coverage_level`]: crate::chunk::Compiler::set_coverage_level
435435
#[cfg(any(feature ="luau", doc))]
436436
#[cfg_attr(docsrs, doc(cfg(feature ="luau")))]
437-
pubfncoverage<F>(&self,mutfunc:F)
437+
pubfncoverage<F>(&self,func:F)
438438
where
439439
F:FnMut(CoverageInfo),
440440
{
@@ -454,13 +454,16 @@ impl Function {
454454
}else{
455455
None
456456
};
457-
let rust_callback =&mut*(dataas*mutF);
458-
rust_callback(CoverageInfo{
459-
function,
460-
line_defined,
461-
depth,
462-
hits: slice::from_raw_parts(hits, size).to_vec(),
463-
});
457+
let rust_callback =&*(dataas*constRefCell<F>);
458+
ifletOk(mut rust_callback) = rust_callback.try_borrow_mut(){
459+
// Call the Rust callback with CoverageInfo
460+
rust_callback(CoverageInfo{
461+
function,
462+
line_defined,
463+
depth,
464+
hits: slice::from_raw_parts(hits, size).to_vec(),
465+
});
466+
}
464467
}
465468

466469
let lua =self.0.lua.lock();
@@ -470,7 +473,8 @@ impl Function {
470473
assert_stack(state,1);
471474

472475
lua.push_ref(&self.0);
473-
let func_ptr =&mut funcas*mutFas*mutc_void;
476+
let func =RefCell::new(func);
477+
let func_ptr =&funcas*constRefCell<F>as*mutc_void;
474478
ffi::lua_getcoverage(state, -1, func_ptr,callback::<F>);
475479
}
476480
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp