[][src]Struct nonminmax::NonMinI64

#[repr(transparent)]pub struct NonMinI64 { /* fields omitted */ }

An integer of type i64 which is known to not equal i64::MIN.

This type allows for niche filling optimization (similar to the existing std::num::NonZero* types) meaning items such as Option<NonMinI64> and Result<NonMinI64, ()> take up the same amount of space as i64.

// Create using `new`, extract value using `get`
let x = NonMinI64::new(123).unwrap();
assert_eq!(x.get(), 123);

// The value cannot be `i64::MIN`
let y = NonMinI64::new(i64::MIN);
assert_eq!(y, None);

// Niche filling optimization works!
use std::mem::size_of;
assert_eq!(size_of::<i64>(), size_of::<NonMinI64>());
assert_eq!(size_of::<i64>(), size_of::<Option<NonMinI64>>());

Implementations

impl NonMinI64[src]

pub fn new(value: i64) -> Option<Self>[src]

Creates an instance of NonMinI64 by checking if the value is not i64::MIN.

pub unsafe fn new_unchecked(value: i64) -> Self[src]

Creates an instance of NonMinI64 without checking if the value is not i64::MIN.

Safety

The value cannot be equal to i64::MIN.

pub fn get(self) -> i64[src]

Returns the integer value.

Trait Implementations

impl Clone for NonMinI64[src]

impl Copy for NonMinI64[src]

impl Debug for NonMinI64[src]

impl Display for NonMinI64[src]

impl Eq for NonMinI64[src]

impl From<NonMinI64> for i64[src]

impl Hash for NonMinI64[src]

impl Ord for NonMinI64[src]

impl PartialEq<NonMinI64> for NonMinI64[src]

impl PartialOrd<NonMinI64> for NonMinI64[src]

impl StructuralEq for NonMinI64[src]

impl StructuralPartialEq for NonMinI64[src]

Auto Trait Implementations

impl Send for NonMinI64

impl Sync for NonMinI64

impl Unpin for NonMinI64

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.