A test package to check that the panic in Rust gets properly handdled:
- The destructor (Drop trait) is executed when panic occurs;
- The error message is converted into R's error message (into the R's strerr stream).
- You need to change the src/rust/Cargo.toml, where must change th local "extendr-api" cargo library path.
- (Probably needed, terminal)
cd src/rust
thencargo clean
to force the cargo library to rebuild. - (R) Run
rextendr::document()
thenrun(0L)
for the non-throwing code,run(0.0)
fo the throwing code. - (Probably needed, R) Run
pkgbuild::clean_dll()
to clean up the existing DLL files. This occationally needed as when you only touched the extendr library, therextendr::document()
may not re-generate the compiled files as it thinks all the source files are unchanged.
- The discussion on extendr: extendr/extendr#278 (comment)