pub struct NumStr<const B: u8 = 10, const U: bool = false, const R: usize = 0, const M: usize = 0, T = usize>(/* private fields */);Expand description
Number to string
§Generic
-
B: the base of the number, should be within the range2..=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 thanM, fill with ‘0’. Default is 0, or no minimum. For signed numberMwill be ignored. -
T: the underlying type of the number. Default isusize.
§Panic
- Invalid base (== 0 or > 16)
Implementations§
Source§impl<T> NumStr<10, false, 0, 0, T>
impl<T> NumStr<10, false, 0, 0, T>
Sourcepub fn new_default(inner: T) -> Self
pub fn new_default(inner: T) -> Self
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T> NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> NumStr<B, U, R, M, T>
Sourcepub fn hexadecimal(self) -> NumStr<16, U, R, M, T>
pub fn hexadecimal(self) -> NumStr<16, U, R, M, T>
Convert to hexadecimal representation.
Sourcepub fn set_custom_base<const NB: u8>(self) -> NumStr<NB, U, R, M, T>
pub fn set_custom_base<const NB: u8>(self) -> NumStr<NB, U, R, M, T>
Set custom base.
The valid range is 2..=16
Sourcepub fn set_uppercase<const NU: bool>(self) -> NumStr<B, NU, R, M, T>
pub fn set_uppercase<const NU: bool>(self) -> NumStr<B, NU, R, M, T>
Set uppercase / lowercase of the number.
Default is lowercase
Note: only works for base > 10
Sourcepub fn set_resize_len<const NR: usize>(self) -> NumStr<B, U, NR, M, T>
pub fn set_resize_len<const NR: usize>(self) -> NumStr<B, U, NR, M, T>
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
Sourcepub fn set_minimum_len<const NM: usize>(self) -> NumStr<B, U, R, NM, T>
pub fn set_minimum_len<const NM: usize>(self) -> NumStr<B, U, R, NM, T>
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
Trait Implementations§
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T> AsRef<T> for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> AsRef<T> for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Clone> Clone for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Clone> Clone for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Debug> Debug for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Debug> Debug for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Deref for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Deref for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T> DerefMut for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> DerefMut for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Ord> Ord for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Ord> Ord for NumStr<B, U, R, M, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T: PartialEq> PartialEq for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: PartialEq> PartialEq for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize, T: PartialOrd> PartialOrd for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: PartialOrd> PartialOrd for NumStr<B, U, R, M, T>
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, usize>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, usize>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i128>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i128>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i16>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i16>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i32>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i32>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i64>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i64>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i8>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, i8>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, isize>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, isize>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u128>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u128>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u16>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u16>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u32>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u32>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u64>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u64>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
Source§impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u8>
impl<const B: u8, const U: bool, const R: usize, const M: usize> StringExtT for NumStr<B, U, R, M, u8>
Source§fn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
Source§fn push_to_string_with_separator(
self,
string: &mut Vec<u8>,
separator: impl SeparatorT,
)
fn push_to_string_with_separator( self, string: &mut Vec<u8>, separator: impl SeparatorT, )
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Source§fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Copy> Copy for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T: Eq> Eq for NumStr<B, U, R, M, T>
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> StructuralPartialEq for NumStr<B, U, R, M, T>
Auto Trait Implementations§
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Freeze for NumStr<B, U, R, M, T>where
T: Freeze,
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> RefUnwindSafe for NumStr<B, U, R, M, T>where
T: RefUnwindSafe,
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Send for NumStr<B, U, R, M, T>where
T: Send,
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Sync for NumStr<B, U, R, M, T>where
T: Sync,
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> Unpin for NumStr<B, U, R, M, T>where
T: Unpin,
impl<const B: u8, const U: bool, const R: usize, const M: usize, T> UnwindSafe for NumStr<B, U, R, M, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)