pub struct RandHexStr<const L: usize = 16, const RP: usize = 1, const LP: usize = 0>;
string_v2
instead, v1 will be removed in 0.9.0.Expand description
Randon hex-like string, with fix length.
For better performance, the underlying random number is generated by
xorshift algorithm then converted to hex string with NumStr
.
By default, the length is 16.
ยงGeneric Parameters
L
: The length of the string. Max 16 (u64).RP
: RepeatL
forRP
times.LP
: Lefted length. Max 16.
For example, if you need a string with length 56, you may specify L
as 16,
RP
as 56 / 16 = 3, and LP
as 56 % 16 = 8.
Since #![feature(generic_const_exprs)]
is not stable, we have to make use
of these complex const generics.
Notice: will check if params are valid when you push this into the
StringExt
, or panic in debug mode, work normally but
slower in release mode.
Implementationsยง
Sourceยงimpl RandHexStr
impl RandHexStr
Sourcepub const fn new_default() -> Self
๐Deprecated since 0.8.0-rc.1: Use string_v2
instead, v1 will be removed in 0.9.0.
pub const fn new_default() -> Self
string_v2
instead, v1 will be removed in 0.9.0.Create a new RandHexStr
and generate simple random hex-like string
with length 16 (default).
ยงExample
let rand_str = RandHexStr::new_default().to_string_ext();
assert_eq!(rand_str.len(), 16);
Sourceยงimpl<const L: usize, const RP: usize, const LP: usize> RandHexStr<L, RP, LP>
impl<const L: usize, const RP: usize, const LP: usize> RandHexStr<L, RP, LP>
Sourcepub const fn new() -> Self
๐Deprecated since 0.8.0-rc.1: Use string_v2
instead, v1 will be removed in 0.9.0.
pub const fn new() -> Self
string_v2
instead, v1 will be removed in 0.9.0.Sourcepub const fn with_l<const NL: usize>(self) -> RandHexStr<NL, RP, LP>
๐Deprecated since 0.8.0-rc.1: Use string_v2
instead, v1 will be removed in 0.9.0.
pub const fn with_l<const NL: usize>(self) -> RandHexStr<NL, RP, LP>
string_v2
instead, v1 will be removed in 0.9.0.Set L
.
You may prefer RandHexStr::<L, RP, LP>::new
.
Sourcepub const fn with_rp<const NRP: usize>(self) -> RandHexStr<L, NRP, LP>
๐Deprecated since 0.8.0-rc.1: Use string_v2
instead, v1 will be removed in 0.9.0.
pub const fn with_rp<const NRP: usize>(self) -> RandHexStr<L, NRP, LP>
string_v2
instead, v1 will be removed in 0.9.0.Set RP
.
You may prefer RandHexStr::<L, RP, LP>::new
.
Sourcepub const fn with_lp<const NLP: usize>(self) -> RandHexStr<L, RP, NLP>
๐Deprecated since 0.8.0-rc.1: Use string_v2
instead, v1 will be removed in 0.9.0.
pub const fn with_lp<const NLP: usize>(self) -> RandHexStr<L, RP, NLP>
string_v2
instead, v1 will be removed in 0.9.0.Set LP
.
You may prefer RandHexStr::<L, RP, LP>::new
.
Trait Implementationsยง
Sourceยงimpl<const L: usize, const RP: usize, const LP: usize> Clone for RandHexStr<L, RP, LP>
impl<const L: usize, const RP: usize, const LP: usize> Clone for RandHexStr<L, RP, LP>
Sourceยงfn clone(&self) -> RandHexStr<L, RP, LP>
fn clone(&self) -> RandHexStr<L, RP, LP>
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSourceยงimpl<const L: usize, const RP: usize, const LP: usize> Default for RandHexStr<L, RP, LP>
impl<const L: usize, const RP: usize, const LP: usize> Default for RandHexStr<L, RP, LP>
Sourceยงfn default() -> RandHexStr<L, RP, LP>
fn default() -> RandHexStr<L, RP, LP>
Sourceยงimpl<const L: usize, const RP: usize, const LP: usize> StringExtT for RandHexStr<L, RP, LP>
impl<const L: usize, const RP: usize, const LP: usize> StringExtT for RandHexStr<L, RP, LP>
Sourceยงfn push_to_string(self, string: &mut Vec<u8>)
fn push_to_string(self, string: &mut Vec<u8>)
string_v2
instead, v1 will be removed in 0.9.0.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, )
string_v2
instead, v1 will be removed in 0.9.0.Sourceยงfn to_string_ext(self) -> String
fn to_string_ext(self) -> String
string_v2
instead, v1 will be removed in 0.9.0.Sourceยงfn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
fn to_string_ext_with_sep(self, separator: impl SeparatorT) -> String
string_v2
instead, v1 will be removed in 0.9.0.Sourceยงfn with_prefix<P: StringExtT>(self, prefix: P) -> impl StringExtT
fn with_prefix<P: StringExtT>(self, prefix: P) -> impl StringExtT
string_v2
instead, v1 will be removed in 0.9.0.Sourceยงfn with_suffix<S: StringExtT>(self, suffix: S) -> impl StringExtT
fn with_suffix<S: StringExtT>(self, suffix: S) -> impl StringExtT
string_v2
instead, v1 will be removed in 0.9.0.