Struct std::num::NonZeroIsize 1.34.0[−][src]
#[repr(transparent)]pub struct NonZeroIsize(_);
An integer that is known not to equal zero.
This enables some memory layout optimization.
For example, Option<NonZeroIsize> is the same size as isize:
use std::mem::size_of; assert_eq!(size_of::<Option<core::num::NonZeroIsize>>(), size_of::<isize>());Run
Implementations
impl NonZeroIsize[src]
impl NonZeroIsize[src]pub const unsafe fn new_unchecked(n: isize) -> NonZeroIsize1.34.0 (const: 1.34.0)[src]
pub const fn new(n: isize) -> Option<NonZeroIsize>1.34.0 (const: 1.47.0)[src]
Creates a non-zero if the given value is not zero.
pub const fn get(self) -> isize1.34.0 (const: 1.34.0)[src]
Returns the value as a primitive type.
impl NonZeroIsize[src]
impl NonZeroIsize[src]pub const fn leading_zeros(self) -> u321.53.0 (const: 1.53.0)[src]
Returns the number of leading zeros in the binary representation of self.
On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.
Examples
Basic usage:
let n = std::num::NonZeroIsize::new(-1isize).unwrap(); assert_eq!(n.leading_zeros(), 0);Run
pub const fn trailing_zeros(self) -> u321.53.0 (const: 1.53.0)[src]
Returns the number of trailing zeros in the binary representation
of self.
On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.
Examples
Basic usage:
let n = std::num::NonZeroIsize::new(0b0101000).unwrap(); assert_eq!(n.trailing_zeros(), 3);Run
Trait Implementations
impl BitOr<NonZeroIsize> for isize1.45.0[src]
impl BitOr<NonZeroIsize> for isize1.45.0[src]type Output = NonZeroIsize
The resulting type after applying the | operator.
pub fn bitor(self, rhs: NonZeroIsize) -> <isize as BitOr<NonZeroIsize>>::Output[src]
impl BitOr<NonZeroIsize> for NonZeroIsize1.45.0[src]
impl BitOr<NonZeroIsize> for NonZeroIsize1.45.0[src]type Output = NonZeroIsize
The resulting type after applying the | operator.
pub fn bitor(
self,
rhs: NonZeroIsize
) -> <NonZeroIsize as BitOr<NonZeroIsize>>::Output[src]
self,
rhs: NonZeroIsize
) -> <NonZeroIsize as BitOr<NonZeroIsize>>::Output
impl BitOr<isize> for NonZeroIsize1.45.0[src]
impl BitOr<isize> for NonZeroIsize1.45.0[src]type Output = NonZeroIsize
The resulting type after applying the | operator.
pub fn bitor(self, rhs: isize) -> <NonZeroIsize as BitOr<isize>>::Output[src]
impl BitOrAssign<NonZeroIsize> for NonZeroIsize1.45.0[src]
impl BitOrAssign<NonZeroIsize> for NonZeroIsize1.45.0[src]pub fn bitor_assign(&mut self, rhs: NonZeroIsize)[src]
impl BitOrAssign<isize> for NonZeroIsize1.45.0[src]
impl BitOrAssign<isize> for NonZeroIsize1.45.0[src]pub fn bitor_assign(&mut self, rhs: isize)[src]
impl Clone for NonZeroIsize[src]
impl Clone for NonZeroIsize[src]pub fn clone(&self) -> NonZeroIsize[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for NonZeroIsize[src]
impl Copy for NonZeroIsize[src]impl Display for NonZeroIsize[src]
impl Display for NonZeroIsize[src]impl Eq for NonZeroIsize[src]
impl Eq for NonZeroIsize[src]impl From<NonZeroI16> for NonZeroIsize1.41.0[src]
impl From<NonZeroI16> for NonZeroIsize1.41.0[src]pub fn from(small: NonZeroI16) -> NonZeroIsize[src]
Converts NonZeroI16 to NonZeroIsize losslessly.
impl From<NonZeroI8> for NonZeroIsize1.41.0[src]
impl From<NonZeroI8> for NonZeroIsize1.41.0[src]pub fn from(small: NonZeroI8) -> NonZeroIsize[src]
Converts NonZeroI8 to NonZeroIsize losslessly.
impl From<NonZeroIsize> for isize1.31.0[src]
impl From<NonZeroIsize> for isize1.31.0[src]pub fn from(nonzero: NonZeroIsize) -> isize[src]
Converts a NonZeroIsize into an isize
impl From<NonZeroU8> for NonZeroIsize1.41.0[src]
impl From<NonZeroU8> for NonZeroIsize1.41.0[src]pub fn from(small: NonZeroU8) -> NonZeroIsize[src]
Converts NonZeroU8 to NonZeroIsize losslessly.
impl FromStr for NonZeroIsize1.35.0[src]
impl FromStr for NonZeroIsize1.35.0[src]type Err = ParseIntError
The associated error which can be returned from parsing.
pub fn from_str(
src: &str
) -> Result<NonZeroIsize, <NonZeroIsize as FromStr>::Err>[src]
src: &str
) -> Result<NonZeroIsize, <NonZeroIsize as FromStr>::Err>
impl Hash for NonZeroIsize[src]
impl Hash for NonZeroIsize[src]impl LowerHex for NonZeroIsize[src]
impl LowerHex for NonZeroIsize[src]impl Ord for NonZeroIsize[src]
impl Ord for NonZeroIsize[src]impl PartialEq<NonZeroIsize> for NonZeroIsize[src]
impl PartialEq<NonZeroIsize> for NonZeroIsize[src]pub fn eq(&self, other: &NonZeroIsize) -> bool[src]
pub fn ne(&self, other: &NonZeroIsize) -> bool[src]
impl PartialOrd<NonZeroIsize> for NonZeroIsize[src]
impl PartialOrd<NonZeroIsize> for NonZeroIsize[src]pub fn partial_cmp(&self, other: &NonZeroIsize) -> Option<Ordering>[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl StructuralEq for NonZeroIsize[src]
impl StructuralEq for NonZeroIsize[src]impl StructuralPartialEq for NonZeroIsize[src]
impl StructuralPartialEq for NonZeroIsize[src]impl TryFrom<NonZeroI128> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroI128> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroI128
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI128>>::Error>[src]
value: NonZeroI128
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI128>>::Error>
Attempts to convert NonZeroI128 to NonZeroIsize.
impl TryFrom<NonZeroI32> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroI32> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroI32
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI32>>::Error>[src]
value: NonZeroI32
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI32>>::Error>
Attempts to convert NonZeroI32 to NonZeroIsize.
impl TryFrom<NonZeroI64> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroI64> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroI64
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI64>>::Error>[src]
value: NonZeroI64
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroI64>>::Error>
Attempts to convert NonZeroI64 to NonZeroIsize.
impl TryFrom<NonZeroIsize> for NonZeroI161.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroI161.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroI16, <NonZeroI16 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroI16, <NonZeroI16 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroI16.
impl TryFrom<NonZeroIsize> for NonZeroU81.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroU81.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroU8, <NonZeroU8 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroU8, <NonZeroU8 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroU8.
impl TryFrom<NonZeroIsize> for NonZeroI321.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroI321.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroI32, <NonZeroI32 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroI32, <NonZeroI32 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroI32.
impl TryFrom<NonZeroIsize> for NonZeroI81.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroI81.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroI8, <NonZeroI8 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroI8, <NonZeroI8 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroI8.
impl TryFrom<NonZeroIsize> for NonZeroU641.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroU641.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroU64, <NonZeroU64 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroU64, <NonZeroU64 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroU64.
impl TryFrom<NonZeroIsize> for NonZeroUsize1.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroUsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroUsize.
impl TryFrom<NonZeroIsize> for NonZeroI1281.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroI1281.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroI128, <NonZeroI128 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroI128, <NonZeroI128 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroI128.
impl TryFrom<NonZeroIsize> for NonZeroU1281.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroU1281.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroU128, <NonZeroU128 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroU128, <NonZeroU128 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroU128.
impl TryFrom<NonZeroIsize> for NonZeroI641.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroI641.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroI64, <NonZeroI64 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroI64, <NonZeroI64 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroI64.
impl TryFrom<NonZeroIsize> for NonZeroU321.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroU321.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroU32, <NonZeroU32 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroU32, <NonZeroU32 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroU32.
impl TryFrom<NonZeroIsize> for NonZeroU161.49.0[src]
impl TryFrom<NonZeroIsize> for NonZeroU161.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroIsize
) -> Result<NonZeroU16, <NonZeroU16 as TryFrom<NonZeroIsize>>::Error>[src]
value: NonZeroIsize
) -> Result<NonZeroU16, <NonZeroU16 as TryFrom<NonZeroIsize>>::Error>
Attempts to convert NonZeroIsize to NonZeroU16.
impl TryFrom<NonZeroU128> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroU128> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroU128
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU128>>::Error>[src]
value: NonZeroU128
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU128>>::Error>
Attempts to convert NonZeroU128 to NonZeroIsize.
impl TryFrom<NonZeroU16> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroU16> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroU16
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU16>>::Error>[src]
value: NonZeroU16
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU16>>::Error>
Attempts to convert NonZeroU16 to NonZeroIsize.
impl TryFrom<NonZeroU32> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroU32> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroU32
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU32>>::Error>[src]
value: NonZeroU32
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU32>>::Error>
Attempts to convert NonZeroU32 to NonZeroIsize.
impl TryFrom<NonZeroU64> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroU64> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroU64
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU64>>::Error>[src]
value: NonZeroU64
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroU64>>::Error>
Attempts to convert NonZeroU64 to NonZeroIsize.
impl TryFrom<NonZeroUsize> for NonZeroIsize1.49.0[src]
impl TryFrom<NonZeroUsize> for NonZeroIsize1.49.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: NonZeroUsize
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroUsize>>::Error>[src]
value: NonZeroUsize
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroUsize>>::Error>
Attempts to convert NonZeroUsize to NonZeroIsize.
impl TryFrom<isize> for NonZeroIsize1.46.0[src]
impl TryFrom<isize> for NonZeroIsize1.46.0[src]type Error = TryFromIntError
The type returned in the event of a conversion error.
pub fn try_from(
value: isize
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<isize>>::Error>[src]
value: isize
) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<isize>>::Error>
Attempts to convert isize to NonZeroIsize.
Auto Trait Implementations
impl RefUnwindSafe for NonZeroIsize
impl RefUnwindSafe for NonZeroIsizeimpl Send for NonZeroIsize
impl Send for NonZeroIsizeimpl Sync for NonZeroIsize
impl Sync for NonZeroIsizeimpl Unpin for NonZeroIsize
impl Unpin for NonZeroIsizeimpl UnwindSafe for NonZeroIsize
impl UnwindSafe for NonZeroIsizeBlanket Implementations
impl<T> Borrow<T> for T where
T: ?Sized, [src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut I
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W[src]
Notable traits for &'_ mut I
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut Wimpl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut I
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W[src]
Notable traits for &'_ mut I
impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<R: Read + ?Sized> Read for &mut Rimpl<W: Write + ?Sized> Write for &mut W