is_tree/unsafe_.rs
1//! Unsafe traits and functions cautiously used in the library but made unsafe to discourage their external use.
2
3pub unsafe trait UnsafeFrom<T> {
4 /// Converts the object from another object.
5 unsafe fn unsafe_from(t: T) -> Self;
6
7}
8
9/// This is required to generalize TreeIterator with a single ::new method.
10pub unsafe trait UnsafeClone {
11 /// Clones the object.
12 unsafe fn unsafe_clone(&self) -> Self;
13}
14
15/// This is required to generalize TreeIterator with a single ::new method.
16pub unsafe trait UnsafeBorrow<'a> {
17 /// The type of the borrowed object.
18 type Borrow;
19 /// Borrows the object.
20 unsafe fn borrow(&'a self) -> Self::Borrow;
21}
22
23/// Makes the reference live longer.
24#[inline]
25pub unsafe fn longer_ref<'longer, T>(t: &T) -> &'longer T { unsafe { &*(t as *const T) } }
26
27/// Makes the mutable reference live longer.
28#[inline]
29pub unsafe fn longer_mut<'longer, T>(t: &mut T) -> &'longer mut T { unsafe { &mut *(t as *mut T) } }