//! Such wrappers are a workaround for the lack of template specialisation available in Rust so far, as the generic `impl<T: Hash> Collapse<T> for T` still requires computing the hash of the internal types before reducing to the `u8` page index.
//! For primitive types, this is unnessisary and causes a (very slight) performance loss.
/// Shim for primitive types to efficiently implement `Collapse`.
///
/// # Notes
/// This newtype is transparent. It is safe to `mem::transmute`() from `Primitive<T>` to `T` and vice versa.
/// However, if `T` does *not* implement `PrimitiveCollapse`, it is undefined behaviour.
///
/// Also, the `collapse()` output from this structure is not guaranteed to be the same as the `collapse()` output from the inner value, so the following code is very unsafe and such patterns should only be used if the programmer is absolutely sure there will be absolutely no difference between `T::collapse` and `Self::collapse`:
/// ```
/// # use smallmap::{Map, Primitive};
/// # use std::mem;
///
/// let mut map: Map<u8, ()> = Map::new();
/// map.insert(120, ());
///
/// let map: Map<Primitive<u8>, ()> = unsafe { mem::transmute(map) };
/// Same as `into_inner`, except only for `Copy` types.
///
/// # Notes
/// The only use of this function is that it is `const fn` on nightly.
/// If you're not using a version of rustc that supports generic `const fn`, this method is identical to `into_inner`.
#[cfg(nightly)]#[inline]pubconstfninto_inner_copy(self)-> T
whereT: Copy
{
self.0
}
#[cfg(not(nightly))]#[inline(always)]#[deprecated = "This function should only be used on Rust nightly. Please use `into_inner` instead"]pubfninto_inner_copy(self)-> T