Skip to content

Commit

Permalink
minor fixes + add is_empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0x17 committed Apr 2, 2024
1 parent 4a64104 commit a506663
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ authors = ["sam0x17"]
description = "Provides a safe interface for interacting with multi-byte strings in Rust, namely IndexedStr, IndexedString, and IndexedSlice"
license = "MIT"
repository = "https://github.com/sam0x17/safe-string"
website = "https://sam0x17.dev"
homepage = "https://sam0x17.dev"
documentation = "https://docs.rs/safe-string"
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ pub trait IndexedStr:
/// [`len`](`IndexedStr::len`) if the string contains multi-byte characters.
fn byte_len(&self) -> usize;

/// Returns `true` if this [`IndexedStr`] is empty (of length 0).
fn is_empty(&self) -> bool {
self.len() == 0
}

/// Returns the character at the given index, if it exists.
fn char_at(&self, index: usize) -> Option<char>;

Expand Down

0 comments on commit a506663

Please sign in to comment.