pub trait GpuResultExt<T> {
// Required methods
fn gpu_ctx(self, prefix: &str) -> Result<T, GpuError>;
fn gpu_ctx_with<F>(self, f: F) -> Result<T, GpuError>
where F: FnOnce(&dyn Display) -> String;
}Expand description
Extension trait that attaches GPU-call context to any Result<T, E>
whose error implements Display.
The two methods mirror the common shapes:
gpu_ctxappends": {err}"to a caller-supplied prefix. This is the vastly dominant shape across the GPU layer (~235 sites in the original audit).gpu_ctx_withtakes a closure that receives the underlying error by&dyn Displayand returns the full reason string. Use it when the reason is not a simpleprefix: errconcatenation (e.g. multi-line, or with the error embedded mid-message).
Cfg note: The trait and its blanket impl are gated to
target_os = "linux" so the symbol literally does not exist on
non-Linux targets. Every callsite is inside a
#[cfg(target_os = "linux")] block that wraps CUDA driver / cuBLAS /
cuSOLVER calls; on non-Linux those blocks are erased and the trait
would have no users. Cfg-gating the definition means a warning-fix
sweep running on non-Linux cannot see “unused” callsites because the
trait itself is absent — the consuming use super::gpu_error::GpuResultExt;
imports must therefore be #[cfg(target_os = "linux")] to match, and
that cfg-symmetry is the architectural contract that prevents the
drop-the-import regression that broke the Linux build in #302.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".