Re: [PATCH v3 2/6] rust: types: avoid `as` casts
From: Alice Ryhl
Date: Fri Nov 08 2024 - 11:34:44 EST
On Fri, Nov 8, 2024 at 4:46 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
>
> Replace `as` casts with `cast{,_mut}` calls which are a bit safer.
>
> In one instance, remove an unnecessary `as` cast without replacement.
>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
One question below, but either way:
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> @@ -333,13 +334,13 @@ impl<T: 'static> ForeignOwnable for Arc<T> {
> type Borrowed<'a> = ArcBorrow<'a, T>;
>
> fn into_foreign(self) -> *const core::ffi::c_void {
> - ManuallyDrop::new(self).ptr.as_ptr() as _
> + ManuallyDrop::new(self).ptr.as_ptr().cast_const().cast()
What's up with this cast_const?
Alice