pub struct RandStr<'r, const L: usize = 32>(/* private fields */);
Expand description
Randon string, with fix length and given charset.
§Generic Parameters
L
: The length of the string. Default is 32.
Notice: must make sure each u8 within the slice is valid single byte UTF-8 char.
If the charset is 0123456789abcdef
, RandHexStr
is recommended and 4~6x
faster than this (when feature feat-random-fast
enabled).
Implementations§
Trait Implementations§
Source§impl<const L: usize> StringExtT for RandStr<'_, L>
impl<const L: usize> StringExtT for RandStr<'_, L>
Source§fn with_prefix<P: StringExtT + Copy>(self, prefix: P) -> impl StringExtT
fn with_prefix<P: StringExtT + Copy>(self, prefix: P) -> impl StringExtT
With prefix.
Source§fn with_suffix<S: StringExtT + Copy>(self, suffix: S) -> impl StringExtT
fn with_suffix<S: StringExtT + Copy>(self, suffix: S) -> impl StringExtT
With suffix.
Source§fn to_string_ext(self) -> String
fn to_string_ext(self) -> String
Encode the value to the string.
Source§impl<const L: usize> StringT for RandStr<'_, L>
impl<const L: usize> StringT for RandStr<'_, L>
Source§fn encode_to_buf(self, string: &mut Vec<u8>)
fn encode_to_buf(self, string: &mut Vec<u8>)
Push the value to the string (the underlying
Vec<u8>
).Source§fn encode_to_buf_with_separator(self, string: &mut Vec<u8>, separator: &str)
fn encode_to_buf_with_separator(self, string: &mut Vec<u8>, separator: &str)
Push the value to the string (the underlying
Vec<u8>
) with a
separator. Read moreSource§fn encode_to_bytes_buf(self, string: &mut BytesMut)
fn encode_to_bytes_buf(self, string: &mut BytesMut)
Push the value to the string (the underlying
bytes::BytesMut
).impl<'r, const L: usize> Copy for RandStr<'r, L>
Auto Trait Implementations§
impl<'r, const L: usize> Freeze for RandStr<'r, L>
impl<'r, const L: usize> RefUnwindSafe for RandStr<'r, L>
impl<'r, const L: usize> Send for RandStr<'r, L>
impl<'r, const L: usize> Sync for RandStr<'r, L>
impl<'r, const L: usize> Unpin for RandStr<'r, L>
impl<'r, const L: usize> UnwindSafe for RandStr<'r, L>
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
Mutably borrows from an owned value. Read more