Skip to content

Commit d268625

Browse files
committed
Add PrimitiveInteger::from_str_radix
1 parent 3bd9327 commit d268625

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/integer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::num::ParseIntError;
2+
13
use crate::{PrimitiveError, PrimitiveNumber, PrimitiveNumberRef};
24

35
/// Trait for all primitive [integer types], including the supertrait [`PrimitiveNumber`].
@@ -264,6 +266,9 @@ pub trait PrimitiveInteger:
264266
/// Converts an integer from little endian to the target's endianness.
265267
fn from_le(value: Self) -> Self;
266268

269+
/// Parses an integer from a string slice with digits in a given base.
270+
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
271+
267272
/// Returns the logarithm of the number with respect to an arbitrary base, rounded down.
268273
fn ilog(self, base: Self) -> u32;
269274

@@ -582,6 +587,7 @@ macro_rules! impl_integer {
582587
forward! {
583588
fn from_be(value: Self) -> Self;
584589
fn from_le(value: Self) -> Self;
590+
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
585591
}
586592
forward! {
587593
fn checked_add(self, rhs: Self) -> Option<Self>;

0 commit comments

Comments
 (0)