//! Extension use std::ops::{ RangeBounds, Bound }; pub trait BoundExt { fn map_impl(self, f: F) -> Bound where F: FnOnce(T) -> U; } impl BoundExt for Bound { #[inline(always)] fn map_impl(self, f: F) -> Bound where F: FnOnce(T) -> U { //! Copied from stdlib use Bound::*; match self { Unbounded => Unbounded, Included(x) => Included(f(x)), Excluded(x) => Excluded(f(x)), } } } #[inline(always)] pub fn erase(_: T) -> () {} /// Get the memory address this reference points to. /// /// # Note /// If `T` is a fat pointer, it is cast to a thin-pointer first. #[inline(always)] pub fn into_addr(r: &T) -> usize { r as *const T as *const std::convert::Infallible as usize }