pub struct NonZeroHexUsize(_);
Expand description

Pointer-sized unsigned nonzero hexadecimal numbers.

use hex_wrapper::NonZeroHexUsize;

// from random value
let rand = NonZeroHexUsize::rand();
let inner = rand.get();
assert_eq!(rand.to_string(), format!("{:x}", inner));

// from given value
let given = NonZeroHexUsize::new(0xa3).unwrap();
assert_eq!(given.to_string(), String::from("a3"));

// from string
let from_str = "a3".parse::<NonZeroHexUsize>();
assert_eq!(from_str.unwrap(), NonZeroHexUsize::new(0xa3).unwrap());

Implementations§

source§

impl NonZeroHexUsize

source

pub fn new(n: usize) -> Option<Self>

source

pub unsafe fn new_unchecked(n: usize) -> Self

Safety

The value must not be zero.

source§

impl NonZeroHexUsize

source

pub fn rand() -> Self

Creates a random hex. This is equivalent to Self::with_rng(rand::thread_rng()).

source

pub fn with_rng(rng: &mut impl Rng) -> Self

Creates a random hex.

source

pub const fn get(self) -> NonZeroUsize

Gets the interior value.

source

pub const fn get_ref(&self) -> &NonZeroUsize

Borrows the interior value.

source

pub fn get_ref_mut(&mut self) -> &mut NonZeroUsize

Gets the mutable reference to the interior value.

source

pub const fn from(n: NonZeroUsize) -> Self

The converse of Self::get(). This is same as the implementation of From.

Trait Implementations§

source§

impl<'a, T> AsExpression<T> for &'a NonZeroHexUsizewhere T: SqlType + TypedExpressionType, &'a NonZeroUsize: AsExpression<T>,

§

type Expression = <&'a NonZeroUsize as AsExpression<T>>::Expression

The expression being returned
source§

fn as_expression(self) -> Self::Expression

Perform the conversion
source§

impl<T> AsExpression<T> for NonZeroHexUsizewhere T: SqlType + TypedExpressionType, NonZeroUsize: AsExpression<T>,

§

type Expression = <NonZeroUsize as AsExpression<T>>::Expression

The expression being returned
source§

fn as_expression(self) -> Self::Expression

Perform the conversion
source§

impl Clone for NonZeroHexUsize

source§

fn clone(&self) -> NonZeroHexUsize

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for NonZeroHexUsize

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for NonZeroHexUsize

source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for NonZeroHexUsize

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<NonZeroHexUsize> for String

source§

fn from(value: NonZeroHexUsize) -> String

Converts to this type from the input type.
source§

impl From<NonZeroUsize> for NonZeroHexUsize

source§

fn from(n: NonZeroUsize) -> Self

Converts to this type from the input type.
source§

impl<T, DB> FromSql<T, DB> for NonZeroHexUsizewhere DB: Backend, NonZeroUsize: FromSql<T, DB>,

source§

fn from_sql(bytes: RawValue<'_, DB>) -> Result<Self>

See the trait documentation.
source§

fn from_nullable_sql( bytes: Option<<DB as HasRawValue<'_>>::RawValue> ) -> Result<Self, Box<dyn Error + Sync + Send + 'static, Global>>

A specialized variant of from_sql for handling null values. Read more
source§

impl FromStr for NonZeroHexUsize

§

type Err = ParseIntError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for NonZeroHexUsize

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for NonZeroHexUsize

source§

fn cmp(&self, other: &NonZeroHexUsize) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<NonZeroHexUsize> for NonZeroHexUsize

source§

fn eq(&self, other: &NonZeroHexUsize) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<NonZeroHexUsize> for NonZeroHexUsize

source§

fn partial_cmp(&self, other: &NonZeroHexUsize) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<DB, ST> Queryable<ST, DB> for NonZeroHexUsizewhere DB: Backend, NonZeroUsize: Queryable<ST, DB>,

§

type Row = <NonZeroUsize as Queryable<ST, DB>>::Row

The Rust type you’d like to map from. Read more
source§

fn build(row: Self::Row) -> Result<Self>

Construct an instance of this type
source§

impl Serialize for NonZeroHexUsize

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T, DB> ToSql<T, DB> for NonZeroHexUsizewhere DB: Backend, NonZeroUsize: ToSql<T, DB>,

source§

fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> Result

See the trait documentation.
source§

impl TryFrom<&str> for NonZeroHexUsize

§

type Error = ParseIntError

The type returned in the event of a conversion error.
source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<usize> for NonZeroHexUsize

§

type Error = <NonZeroUsize as TryFrom<usize>>::Error

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for NonZeroHexUsize

source§

impl Eq for NonZeroHexUsize

source§

impl StructuralEq for NonZeroHexUsize

source§

impl StructuralPartialEq for NonZeroHexUsize

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,