pub trait FromSciString: Sized {
// Required method
fn from_sci_string_with_options(
s: &str,
options: FromSciStringOptions,
) -> Option<Self>;
// Provided method
fn from_sci_string(s: &str) -> Option<Self> { ... }
}
Expand description
Converts a &str
, possibly in scientific notation, to a number.
Required Methods§
Sourcefn 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§
Sourcefn 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
.
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 FromSciString for i8
impl FromSciString for i8
Source§fn 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.
Source§impl FromSciString for i16
impl FromSciString for i16
Source§fn 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.
Source§impl FromSciString for i32
impl FromSciString for i32
Source§fn 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.
Source§impl FromSciString for i64
impl FromSciString for i64
Source§fn 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.
Source§impl FromSciString for i128
impl FromSciString for i128
Source§fn 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.
Source§impl FromSciString for isize
impl FromSciString for isize
Source§fn 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.
Source§impl FromSciString for u8
impl FromSciString for u8
Source§fn 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.
Source§impl FromSciString for u16
impl FromSciString for u16
Source§fn 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.
Source§impl FromSciString for u32
impl FromSciString for u32
Source§fn 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.
Source§impl FromSciString for u64
impl FromSciString for u64
Source§fn 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.
Source§impl FromSciString for u128
impl FromSciString for u128
Source§fn 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.
Source§impl FromSciString for usize
impl FromSciString for usize
Source§fn 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.