1 | #![deny (unsafe_op_in_unsafe_fn)] |
2 | #![allow (clippy::needless_doctest_main, clippy::partialeq_ne_impl)] |
3 | |
4 | #[cfg (feature = "alloc" )] |
5 | pub use self::slice::SliceExt; |
6 | |
7 | pub mod alloc; |
8 | |
9 | #[cfg (feature = "alloc" )] |
10 | pub mod boxed; |
11 | |
12 | #[cfg (feature = "alloc" )] |
13 | mod raw_vec; |
14 | |
15 | #[cfg (feature = "alloc" )] |
16 | pub mod vec; |
17 | |
18 | #[cfg (feature = "alloc" )] |
19 | mod macros; |
20 | |
21 | #[cfg (feature = "alloc" )] |
22 | mod slice; |
23 | |
24 | #[cfg (feature = "alloc" )] |
25 | #[track_caller ] |
26 | #[inline (always)] |
27 | #[cfg (debug_assertions)] |
28 | unsafe fn assume(v: bool) { |
29 | if !v { |
30 | core::unreachable!() |
31 | } |
32 | } |
33 | |
34 | #[cfg (feature = "alloc" )] |
35 | #[track_caller ] |
36 | #[inline (always)] |
37 | #[cfg (not(debug_assertions))] |
38 | unsafe fn assume(v: bool) { |
39 | if !v { |
40 | unsafe { |
41 | core::hint::unreachable_unchecked(); |
42 | } |
43 | } |
44 | } |
45 | |
46 | #[cfg (feature = "alloc" )] |
47 | #[inline (always)] |
48 | fn addr<T>(x: *const T) -> usize { |
49 | #[allow (clippy::useless_transmute, clippy::transmutes_expressible_as_ptr_casts)] |
50 | unsafe { |
51 | core::mem::transmute(src:x) |
52 | } |
53 | } |
54 | |
55 | #[cfg (feature = "alloc" )] |
56 | #[inline (always)] |
57 | fn invalid_mut<T>(addr: usize) -> *mut T { |
58 | #[allow (clippy::useless_transmute, clippy::transmutes_expressible_as_ptr_casts)] |
59 | unsafe { |
60 | core::mem::transmute(src:addr) |
61 | } |
62 | } |
63 | |