Struct StringUtils

Source
pub struct StringUtils;
Expand description

字符串工具

Implementations§

Source§

impl StringUtils

Source

pub fn camel_to_snake(s: &str) -> String

驼峰转下划线

Source

pub fn snake_to_camel(s: &str) -> String

下划线转驼峰

Source

pub fn capitalize(s: &str) -> String

首字母大写

Source

pub fn uncapitalize(s: &str) -> String

首字母小写

Source

pub fn uuid() -> String

生成UUID

Source

pub fn random_string(length: usize) -> String

生成随机字符串

Source

pub fn to_camel_case(s: &str) -> String

下划线转驼峰

Source

pub fn to_snake_case(s: &str) -> String

驼峰转下划线

Source

pub fn substring(s: &str, start: usize, end: Option<usize>) -> Cow<'_, str>

截取字符串

Source

pub fn regex_match(s: &str, pattern: &Regex) -> bool

缓存正则表达式

Source

pub fn regex_from_pattern(pattern: &str) -> Regex

Source

pub fn option_is_empty(option: &Option<String>) -> bool

Source

pub fn string_to_vec_u8(s: &str) -> Vec<u8>

Source

pub fn deserialize_str_to_i32<'de, D>( deserializer: D, ) -> Result<Option<i32>, D::Error>
where D: Deserializer<'de>,

Source

pub fn serialize_i32_to_string<S>( value: &Option<i32>, serializer: S, ) -> Result<S::Ok, S::Error>
where S: Serializer,

Source

pub fn serialize_vec_u8_to_string<S>( value: &Option<Vec<u8>>, serializer: S, ) -> Result<S::Ok, S::Error>
where S: Serializer,

Source

pub fn redis_info_to_map(info: &str) -> HashMap<String, String>

Source

pub fn redis_command_stats_to_map(info: &str) -> Vec<HashMap<String, String>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V