You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
774 B
38 lines
774 B
//! Extension
|
|
use std::ops::{
|
|
RangeBounds,
|
|
Bound
|
|
};
|
|
pub trait BoundExt<T>
|
|
{
|
|
fn map_impl<U, F>(self, f: F) -> Bound<U>
|
|
where F: FnOnce(T) -> U;
|
|
}
|
|
|
|
impl<T> BoundExt<T> for Bound<T>
|
|
{
|
|
#[inline(always)]
|
|
fn map_impl<U, F>(self, f: F) -> Bound<U>
|
|
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>(_: 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<T: ?Sized>(r: &T) -> usize
|
|
{
|
|
r as *const T as *const std::convert::Infallible as usize
|
|
}
|