rootcause_internals/
util.rs

1//! Internal utility types and traits.
2
3/// Helper trait to force explicit turbofish syntax on pointer casts.
4///
5/// This trait prevents accidental type inference on calls like `ptr.cast::<U>()`,
6/// ensuring callers explicitly specify the target type. This helps catch bugs
7/// where the wrong type might be silently inferred.
8///
9/// The trait's associated type `Target` is always equal to `Self`, but the
10/// compiler cannot infer it automatically, requiring explicit specification.
11pub(crate) trait CastTo: 'static {
12    /// Target type of the cast. Always equal to `Self`, but cannot be inferred
13    /// by the compiler, forcing explicit turbofish syntax.
14    type Target: 'static;
15}
16
17impl<T: 'static> CastTo for T {
18    type Target = T;
19}
20
21/// Marker type used when type-erasing reports or attachments.
22///
23/// This zero-sized type serves as a placeholder in generic type parameters
24/// when the actual concrete type has been erased. For example,
25/// `AttachmentData<Erased>` represents an attachment whose concrete type
26/// is unknown at the current scope.
27///
28/// Using a distinct marker type (rather than `()`) makes the intent clearer
29/// in type signatures and error messages.
30pub(crate) struct Erased;