Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/libunicode/u_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ pub trait UnicodeStrPrelude for Sized? {
/// ```
fn is_whitespace(&self) -> bool;

/// Returns true if the string contains only alphabetic code
/// points.
///
/// Alphabetic characters are determined by `char::is_alphabetic`.
///
/// # Example
///
/// ```rust
/// assert!("Löwe老虎Léopard".is_alphabetic());
/// assert!("".is_alphabetic());
///
/// assert!( !" &*~".is_alphabetic());
/// ```
fn is_alphabetic(&self) -> bool;

/// Returns true if the string contains only alphanumeric code
/// points.
///
Expand Down Expand Up @@ -149,6 +164,9 @@ impl UnicodeStrPrelude for str {
#[inline]
fn is_whitespace(&self) -> bool { self.chars().all(|c| c.is_whitespace()) }

#[inline]
fn is_alphabetic(&self) -> bool { self.chars().all(|c| c.is_alphabetic()) }

#[inline]
fn is_alphanumeric(&self) -> bool { self.chars().all(|c| c.is_alphanumeric()) }

Expand Down