zr/ptr.rs
1// Copyright 2026 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/// Extension trait for references to obtain a mutable raw pointer.
6pub trait ToMutPtr {
7 /// The target type of the pointer.
8 type Target: ?Sized;
9
10 /// Casts the reference to a mutable raw pointer.
11 fn to_mut_ptr(&self) -> *mut Self::Target;
12}
13
14impl<T: ?Sized> ToMutPtr for T {
15 type Target = T;
16
17 #[inline(always)]
18 fn to_mut_ptr(&self) -> *mut T {
19 self as *const T as *mut T
20 }
21}