@@ -468,6 +468,22 @@ impl CheetahString {
468468 self . as_str ( ) . starts_with ( pat. as_ref ( ) )
469469 }
470470
471+ /// Returns `true` if the string starts with the given character.
472+ ///
473+ /// # Examples
474+ ///
475+ /// ```
476+ /// use cheetah_string::CheetahString;
477+ ///
478+ /// let s = CheetahString::from("hello world");
479+ /// assert!(s.starts_with_char('h'));
480+ /// assert!(!s.starts_with_char('w'));
481+ /// ```
482+ #[ inline]
483+ pub fn starts_with_char ( & self , pat : char ) -> bool {
484+ self . as_str ( ) . starts_with ( pat)
485+ }
486+
471487 /// Returns `true` if the string ends with the given pattern.
472488 ///
473489 /// # Examples
@@ -484,6 +500,22 @@ impl CheetahString {
484500 self . as_str ( ) . ends_with ( pat. as_ref ( ) )
485501 }
486502
503+ /// Returns `true` if the string ends with the given character.
504+ ///
505+ /// # Examples
506+ ///
507+ /// ```
508+ /// use cheetah_string::CheetahString;
509+ ///
510+ /// let s = CheetahString::from("hello world");
511+ /// assert!(s.ends_with_char('d'));
512+ /// assert!(!s.ends_with_char('h'));
513+ /// ```
514+ #[ inline]
515+ pub fn ends_with_char ( & self , pat : char ) -> bool {
516+ self . as_str ( ) . ends_with ( pat)
517+ }
518+
487519 /// Returns `true` if the string contains the given pattern.
488520 ///
489521 /// # Examples
@@ -500,6 +532,22 @@ impl CheetahString {
500532 self . as_str ( ) . contains ( pat. as_ref ( ) )
501533 }
502534
535+ /// Returns `true` if the string contains the given character.
536+ ///
537+ /// # Examples
538+ ///
539+ /// ```
540+ /// use cheetah_string::CheetahString;
541+ ///
542+ /// let s = CheetahString::from("hello world");
543+ /// assert!(s.contains_char('o'));
544+ /// assert!(!s.contains_char('x'));
545+ /// ```
546+ #[ inline]
547+ pub fn contains_char ( & self , pat : char ) -> bool {
548+ self . as_str ( ) . contains ( pat)
549+ }
550+
503551 /// Returns the byte index of the first occurrence of the pattern, or `None` if not found.
504552 ///
505553 /// # Examples
0 commit comments