From 2c07b2aada4c1f2f1b8072d72c3777c01c175953 Mon Sep 17 00:00:00 2001 From: soruh Date: Fri, 31 Jul 2026 04:27:35 +0200 Subject: [PATCH] Prove retained casts require unsafe --- src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e021bfb..4d16d8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,6 +152,13 @@ impl TypeErasedVec { /// Matching size alone is insufficient because the allocation must also have /// the alignment required by `T`. The caller must additionally ensure that /// every existing element is valid as `T` and can be soundly dropped as `T`. + /// + /// ```compile_fail + /// use type_erased_vec_capacity::TypeErasedVec; + /// + /// let mut erased = TypeErasedVec::new(vec![0_u32]); + /// let _guard = erased.cast_type::(); + /// ``` pub unsafe fn cast_type(&mut self) -> ContentGuard<'_, T> { debug_assert_eq!(self.layout, Layout::new::());