Skip to content

Commit

Permalink
Add is_empty to P{,C}WSTR
Browse files Browse the repository at this point in the history
  • Loading branch information
tyilo committed Apr 22, 2024
1 parent b3833cf commit 5d88893
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/libs/core/src/strings/pcwstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ impl PCWSTR {
len
}

/// Returns `true` if the string length is zero, and `false` otherwise.
///
/// # Safety
///
/// The `PCWSTR`'s pointer needs to be valid for reads up until and including the next `\0`.
pub unsafe fn is_empty(&self) -> bool {
self.len() == 0
}

/// String data without the trailing 0
///
/// # Safety
Expand Down
9 changes: 9 additions & 0 deletions crates/libs/core/src/strings/pwstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ impl PWSTR {
PCWSTR(self.0).len()
}

/// Returns `true` if the string length is zero, and `false` otherwise.
///
/// # Safety
///
/// The `PWSTR`'s pointer needs to be valid for reads up until and including the next `\0`.
pub unsafe fn is_empty(&self) -> bool {
self.len() == 0
}

/// String data without the trailing 0.
///
/// # Safety
Expand Down

0 comments on commit 5d88893

Please sign in to comment.