FromBStrRadix

Trait FromBStrRadix 

Source
pub trait FromBStrRadix: Sized {
    // Required method
    fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>;
}
Expand description

An extension trait for from_bstr_radix.

Required Methods§

Source

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u8::from_bstr_radix(b"A", 16), Ok(10));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromBStrRadix for i8

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(i8::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for i16

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(i16::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for i32

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(i32::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for i64

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(i64::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for i128

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(i128::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for isize

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(isize::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for u8

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u8::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for u16

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u16::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for u32

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u32::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for u64

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u64::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for u128

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(u128::from_bstr_radix(b"A", 16), Ok(10));
Source§

impl FromBStrRadix for usize

Source§

fn from_bstr_radix(src: &[u8], radix: u32) -> Result<Self, ParseIntError>

Converts a string slice in a given base to an integer.

The string is expected to be an optional + or - sign followed by digits. Leading and trailing whitespace represent an error. Digits are a subset of these characters, depending on radix:

  • 0-9
  • a-z
  • A-Z
§Panics

This function panics if radix is not in the range from 2 to 36.

§Examples

Basic usage:

use bstr_parse::*;

assert_eq!(usize::from_bstr_radix(b"A", 16), Ok(10));

Implementors§