MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / drop

Method drop

crates/cust/src/module.rs:457–472  ·  view source on GitHub ↗

Destroy a `Module`, returning an error. Destroying a module can return errors from previous asynchronous work. This function destroys the given module and returns the error and the un-destroyed module on failure. # Example ``` # use cust::*; # use std::error::Error; # fn main() -> Result<(), Box > { # let _ctx = quick_init()?; use cust::module::Module; use std::ffi::CString; let ptx

(mut module: Module)

Source from the content-addressed store, hash-verified

455 /// # }
456 /// ```
457 pub fn drop(mut module: Module) -> DropResult<Module> {
458 if module.inner.is_null() {
459 return Ok(());
460 }
461
462 unsafe {
463 let inner = mem::replace(&mut module.inner, ptr::null_mut());
464 match cuda::cuModuleUnload(inner).to_result() {
465 Ok(()) => {
466 mem::forget(module);
467 Ok(())
468 }
469 Err(e) => Err((e, Module { inner })),
470 }
471 }
472 }
473}
474impl Drop for Module {
475 fn drop(&mut self) {

Callers

nothing calls this directly

Calls 2

is_nullMethod · 0.80
to_resultMethod · 0.45

Tested by

no test coverage detected