pointer_identity/pointer/
builtin.rs

1use super::Pointer;
2use std::{rc::Rc, sync::Arc};
3
4impl<T: ?Sized> Pointer for Arc<T> {
5    type Target = T;
6
7    fn get(&self) -> *const Self::Target {
8        Arc::as_ptr(self)
9    }
10}
11
12impl<T: ?Sized> Pointer for Rc<T> {
13    type Target = T;
14
15    fn get(&self) -> *const Self::Target {
16        Rc::as_ptr(self)
17    }
18}
19
20impl<T: ?Sized> Pointer for Box<T> {
21    type Target = T;
22
23    fn get(&self) -> *const Self::Target {
24        &**self as *const Self::Target
25    }
26}
27
28impl<T> Pointer for Vec<T> {
29    type Target = T;
30
31    fn get(&self) -> *const Self::Target {
32        self.as_ptr()
33    }
34}
35
36impl<T> Pointer for &[T] {
37    type Target = T;
38
39    fn get(&self) -> *const Self::Target {
40        self.as_ptr()
41    }
42}
43
44impl<const LEN: usize, T> Pointer for &[T; LEN] {
45    type Target = T;
46
47    fn get(&self) -> *const Self::Target {
48        self.as_ptr()
49    }
50}