# Struct deranged::OptionRangedI8

source · `pub struct OptionRangedI8<const MIN: i8, const MAX: i8>(/* private fields */);`

## Expand description

A `RangedI8`

that is optional. Equivalent to `Option<RangedI8>`

with niche value optimization.

If `MIN`

is `i8::MIN`

*and* `MAX`

is `i8::MAX`

then compilation will fail. This is because there is no way to represent the niche value.

This type is useful when you need to store an optional ranged value in a struct, but
do not want the overhead of an `Option`

type. This reduces the size of the struct
overall, and is particularly useful when you have a large number of optional fields.
Note that most operations must still be performed on the `Option`

type, which is
obtained with `OptionRangedI8::get`

.

## Implementations§

source§### impl<const MIN: i8, const MAX: i8> OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> OptionRangedI8<MIN, MAX>

source#### pub const fn Some(value: RangedI8<MIN, MAX>) -> Self

#### pub const fn Some(value: RangedI8<MIN, MAX>) -> Self

Creates an optional ranged value that is present.

source#### pub const fn get(self) -> Option<RangedI8<MIN, MAX>>

#### pub const fn get(self) -> Option<RangedI8<MIN, MAX>>

Returns the value as the standard library’s `Option`

type.

source#### pub const unsafe fn some_unchecked(value: i8) -> Self

#### pub const unsafe fn some_unchecked(value: i8) -> Self

Creates an optional ranged integer without checking the value.

##### §Safety

The value must be within the range `MIN..=MAX`

. As the value used for niche
value optimization is unspecified, the provided value must not be the niche
value.

#### pub const fn get_primitive(self) -> Option<i8>

## Trait Implementations§

source§### impl<const MIN: i8, const MAX: i8> Clone for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Clone for OptionRangedI8<MIN, MAX>

source§#### fn clone(&self) -> OptionRangedI8<MIN, MAX>

#### fn clone(&self) -> OptionRangedI8<MIN, MAX>

1.0.0 · source§#### fn clone_from(&mut self, source: &Self)

#### fn clone_from(&mut self, source: &Self)

`source`

. Read moresource§### impl<'de, const MIN: i8, const MAX: i8> Deserialize<'de> for OptionRangedI8<MIN, MAX>

### impl<'de, const MIN: i8, const MAX: i8> Deserialize<'de> for OptionRangedI8<MIN, MAX>

source§#### fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

#### fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

source§#### #[doc(hidden)] fn deserialize_in_place<D>(
deserializer: D,
place: &mut Self,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,

#### #[doc(hidden)] fn deserialize_in_place<D>(
deserializer: D,
place: &mut Self,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,

`self`

from the given Deserializer. Read moresource§### impl<const MIN: i8, const MAX: i8> Distribution<OptionRangedI8<MIN, MAX>> for Standard

### impl<const MIN: i8, const MAX: i8> Distribution<OptionRangedI8<MIN, MAX>> for Standard

source§#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> OptionRangedI8<MIN, MAX>

#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> OptionRangedI8<MIN, MAX>

`T`

, using `rng`

as the source of randomness.source§#### fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>

#### fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>

`T`

, using `rng`

as
the source of randomness. Read moresource§### impl<const MIN: i8, const MAX: i8> Eq for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Eq for OptionRangedI8<MIN, MAX>

#### #[doc(hidden)] fn assert_receiver_is_total_eq(&self)

source§### impl<const MIN: i8, const MAX: i8> From<Option<RangedI8<MIN, MAX>>> for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> From<Option<RangedI8<MIN, MAX>>> for OptionRangedI8<MIN, MAX>

source§### impl<const MIN: i8, const MAX: i8> From<OptionRangedI8<MIN, MAX>> for Option<RangedI8<MIN, MAX>>

### impl<const MIN: i8, const MAX: i8> From<OptionRangedI8<MIN, MAX>> for Option<RangedI8<MIN, MAX>>

source§#### fn from(value: OptionRangedI8<MIN, MAX>) -> Self

#### fn from(value: OptionRangedI8<MIN, MAX>) -> Self

source§### impl<const MIN: i8, const MAX: i8> Ord for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Ord for OptionRangedI8<MIN, MAX>

source§### impl<const MIN_A: i8, const MAX_A: i8, const MIN_B: i8, const MAX_B: i8> PartialEq<OptionRangedI8<MIN_B, MAX_B>> for OptionRangedI8<MIN_A, MAX_A>

### impl<const MIN_A: i8, const MAX_A: i8, const MIN_B: i8, const MAX_B: i8> PartialEq<OptionRangedI8<MIN_B, MAX_B>> for OptionRangedI8<MIN_A, MAX_A>

source§#### fn eq(&self, other: &OptionRangedI8<MIN_B, MAX_B>) -> bool

#### fn eq(&self, other: &OptionRangedI8<MIN_B, MAX_B>) -> bool

`self`

and `other`

values to be equal, and is used by `==`

.source§### impl<const MIN_A: i8, const MAX_A: i8, const MIN_B: i8, const MAX_B: i8> PartialOrd<OptionRangedI8<MIN_B, MAX_B>> for OptionRangedI8<MIN_A, MAX_A>

### impl<const MIN_A: i8, const MAX_A: i8, const MIN_B: i8, const MAX_B: i8> PartialOrd<OptionRangedI8<MIN_B, MAX_B>> for OptionRangedI8<MIN_A, MAX_A>

### impl<const MIN: i8, const MAX: i8> Copy for OptionRangedI8<MIN, MAX>

## Auto Trait Implementations§

### impl<const MIN: i8, const MAX: i8> Freeze for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> RefUnwindSafe for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Send for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Sync for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> Unpin for OptionRangedI8<MIN, MAX>

### impl<const MIN: i8, const MAX: i8> UnwindSafe for OptionRangedI8<MIN, MAX>

## Blanket Implementations§

source§### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

source§#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

source§### impl<T> CloneToUninit for Twhere
T: Clone,

### impl<T> CloneToUninit for Twhere
T: Clone,

source§#### unsafe fn clone_to_uninit(&self, dst: *mut T)

#### unsafe fn clone_to_uninit(&self, dst: *mut T)

`clone_to_uninit`

)