Destroy a `UnifiedBox`, returning an error. Deallocating unified memory can return errors from previous asynchronous work. This function destroys the given box and returns the error and the un-destroyed box on failure. # Example ``` # let _context = cust::quick_init().unwrap(); use cust::memory::*; let x = UnifiedBox::new(5).unwrap(); match UnifiedBox::drop(x) { Ok(()) => println!("Successfully
(mut uni_box: UnifiedBox<T>)
| 227 | /// } |
| 228 | /// ``` |
| 229 | pub fn drop(mut uni_box: UnifiedBox<T>) -> DropResult<UnifiedBox<T>> { |
| 230 | if uni_box.ptr.is_null() { |
| 231 | return Ok(()); |
| 232 | } |
| 233 | |
| 234 | let ptr = mem::replace(&mut uni_box.ptr, UnifiedPointer::null()); |
| 235 | unsafe { |
| 236 | match cuda_free_unified(ptr) { |
| 237 | Ok(()) => { |
| 238 | mem::forget(uni_box); |
| 239 | Ok(()) |
| 240 | } |
| 241 | Err(e) => Err((e, UnifiedBox { ptr })), |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | impl<T: DeviceCopy> Drop for UnifiedBox<T> { |
| 247 | fn drop(&mut self) { |
nothing calls this directly
no test coverage detected