Trait malachite_base::num::conversion::traits::FromSciString
source · [−]pub trait FromSciString: Sized {
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<Self>;
fn from_sci_string(s: &str) -> Option<Self> { ... }
}
Expand description
Converts a &str
, possibly in scientific notation, to a number.
Required Methods
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<Self>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<Self>
Converts a &str
, possibly in scientific notation, to a number.
Provided Methods
fn from_sci_string(s: &str) -> Option<Self>
fn from_sci_string(s: &str) -> Option<Self>
Converts a &str
, possibly in scientific notation, to a number, using the default
FromSciStringOptions
.
Implementations on Foreign Types
sourceimpl FromSciString for u8
impl FromSciString for u8
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u8>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u8>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for u16
impl FromSciString for u16
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u16>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u16>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for u32
impl FromSciString for u32
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u32>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u32>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for u64
impl FromSciString for u64
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u64>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u64>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for u128
impl FromSciString for u128
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u128>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<u128>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for usize
impl FromSciString for usize
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<usize>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<usize>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for i8
impl FromSciString for i8
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i8>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i8>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for i16
impl FromSciString for i16
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i16>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i16>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for i32
impl FromSciString for i32
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i32>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i32>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for i64
impl FromSciString for i64
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i64>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i64>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for i128
impl FromSciString for i128
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i128>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<i128>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.
sourceimpl FromSciString for isize
impl FromSciString for isize
sourcefn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<isize>
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions
) -> Option<isize>
Converts a String
, possibly in scientfic notation, to a primitive integer.
Use FromSciStringOptions
to specify the
base (from 2 to 36, inclusive) and the rounding mode, in case rounding is necessary
because the string represents a non-integer.
If the base is greater than 10, the higher digits are represented by the letters
'a'
through 'z'
or 'A'
through 'Z'
; the case doesn’t matter and doesn’t
need to be consistent.
Exponents are allowed, and are indicated using the character 'e'
or 'E'
. If the
base is 15 or greater, an ambiguity arises where it may not be clear whether 'e'
is a digit or an exponent indicator. To resolve this ambiguity, always use a '+'
or '-'
sign after the exponent indicator when the base is 15 or greater.
The exponent itself is always parsed using base 10.
Decimal (or other-base) points are allowed. These are most useful in conjunction
with exponents, but they may be used on their own. If the string represents a
non-integer, the rounding mode specified in options
is used to round to an
integer.
If the string is unparseable or parses to an out-of-range integer, None
is
returned. None
is also returned if the rounding mode in options is Exact
, but
rounding is necessary.
Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is s.len()
.
Examples
See here.