Prove retained casts require unsafe
This commit is contained in:
@@ -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::<i32>();
|
||||
/// ```
|
||||
pub unsafe fn cast_type<T: 'static>(&mut self) -> ContentGuard<'_, T> {
|
||||
debug_assert_eq!(self.layout, Layout::new::<T>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user