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)
| 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 | } |
| 474 | impl Drop for Module { |
| 475 | fn drop(&mut self) { |