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

Method drop

crates/cust/src/stream.rs:312–327  ·  view source on GitHub ↗

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

(mut stream: Stream)

Source from the content-addressed store, hash-verified

310 /// # }
311 /// ```
312 pub fn drop(mut stream: Stream) -> DropResult<Stream> {
313 if stream.inner.is_null() {
314 return Ok(());
315 }
316
317 unsafe {
318 let inner = mem::replace(&mut stream.inner, ptr::null_mut());
319 match cuda::cuStreamDestroy_v2(inner).to_result() {
320 Ok(()) => {
321 mem::forget(stream);
322 Ok(())
323 }
324 Err(e) => Err((e, Stream { inner })),
325 }
326 }
327 }
328}
329impl Drop for Stream {
330 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