diff --git a/crates/libs/core/src/strings/pcwstr.rs b/crates/libs/core/src/strings/pcwstr.rs index fb8e843b46..14086c273e 100644 --- a/crates/libs/core/src/strings/pcwstr.rs +++ b/crates/libs/core/src/strings/pcwstr.rs @@ -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 diff --git a/crates/libs/core/src/strings/pwstr.rs b/crates/libs/core/src/strings/pwstr.rs index 6349f38b72..8a4281b0d4 100644 --- a/crates/libs/core/src/strings/pwstr.rs +++ b/crates/libs/core/src/strings/pwstr.rs @@ -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