macro_toolset ::string Struct NumStr Copy item path Source pub struct NumStr<const B: u8 = 10, const U: bool = false, const R: usize = 0, const M: usize = 0, T = usize >();Expand description Number to string
§ Generic
B: the base of the number, should be within the range 2..=16. Default
is 10.
U: whether to use uppercase for hex. Default is lowercase (false)
R: the resize length of the string. The overflow part will be truncated,
and the insufficient part will be filled with ‘0’. Default is 0, or no
resize.
M: the minimum length of the string, if the length of the string is less
than M, fill with ‘0’. Default is 0, or no minimum. For signed number
M will be ignored.
T: the underlying type of the number. Default is usize.
§ Panic
Invalid base (== 0 or > 16)
§ Create a new NumStr with the given number.
With default settings of B, U, R, M:
See NumStr for details.
If you want a hexadecimal number, chains with NumStr::hexadecimal() .
§ Notice
For negative number, R, M will not make sense
§ Examples
NumStr::new_default(123_i16 )
§ Create a new NumStr with the given number.
With default settings of B, U, R, M:
See NumStr for details.
§ Notice
For negative number, R, M will not make sense
§ Examples
NumStr::new_default_hex(123_i16 )
Create a new NumStr with the given number.
Convert to decimal representation.
Convert to hexadecimal representation.
Set custom base.
The valid range is 2..=16
Set uppercase / lowercase of the number.
Default is lowercase
Note: only works for base > 10
Set whether to resize the string to len length.
The overflow part will be truncated, and the insufficient part will be
filled with ‘0’
Default is not resize
Note: see Vec::resize for details
Set the minimum length of the string.
The insufficient part will be filled with ‘0’.
Default is not minimum
Note: if set Self::should_resize, the minimum length will be ignored
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Encode the number to the str
Converts this type into a shared reference of the (usually inferred) input type.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Compares and returns the maximum of two values.
Read more Compares and returns the minimum of two values.
Read more Restrict a value to a certain interval.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Push the value to the string.
Push the value to the string with a separator.
Read more Encode the value to the string.
Push the value to the string with separator
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dst.
Read more Returns the argument unchanged.
Converts to this type from a reference to the input type.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
🔬 This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more 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.