pub enum PrimIntKind {
    U8,
    U16,
    U32,
    U64,
    U128,
    Usize,
    I8,
    I16,
    I32,
    I64,
    I128,
    Isize,
}
Expand description

Enumerates primitive integer kinds as per Rust’s reference

Examples

Stable Rust

use prim_int_kind::PrimIntKind;

let res_kind = "u16".parse();
assert_eq!(res_kind, Ok(PrimIntKind::U16));

With const_trait_impl nightly feature

Cargo.toml

[features]
const_trait_impl = ["prim_int_kind/const_trait_impl"]

src/main.rs

#![cfg_attr(any(doc,test,doctest, feature = "const_trait_impl"), feature(const_trait_impl))]
// Run via `cargo run --features const_trait_impl`

use core::str::FromStr;
use prim_int_kind::{PrimIntKind, PrimIntKindParsingError};

#[cfg(any(doc,test,doctest, feature = "const_trait_impl"))]
const res_kind: Result<PrimIntKind, PrimIntKindParsingError> = PrimIntKind::from_str("u16");
#[cfg(not(any(doc,test,doctest, feature = "const_trait_impl")))]
let res_kind: Result<PrimIntKind, PrimIntKindParsingError> = PrimIntKind::from_str("u16");
assert_eq!(res_kind, Ok(PrimIntKind::U16));

Variants

U8

U16

U32

U64

U128

Usize

I8

I16

I32

I64

I128

Isize

Trait Implementations

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.