diff options
| author | Gabriel Bjørnager Jensen <gabriel@achernar.io> | 2025-02-19 10:36:21 +0100 |
|---|---|---|
| committer | Gabriel Bjørnager Jensen <gabriel@achernar.io> | 2025-02-20 17:51:00 +0100 |
| commit | 817b0932fa66ee8fd6e695f9ec74804a6c360269 (patch) | |
| tree | 4f64cd91616c3497be1552f32472d50c9a954b1e /library/core | |
| parent | 5986ff05d8480da038dd161b3a6aa79ff364a851 (diff) | |
| download | rust-817b0932fa66ee8fd6e695f9ec74804a6c360269.tar.gz rust-817b0932fa66ee8fd6e695f9ec74804a6c360269.zip | |
Implement 'PartialEq<{&Self, CString, Cow<Self>}>' for 'CStr'; Implement 'PartialEq<{CStr, &CStr, Cow<CStr>}>' for 'CString'; Implement 'PartialEq<{CStr, &CStr, CString}>' for 'Cow<CStr>';
Diffstat (limited to 'library/core')
| -rw-r--r-- | library/core/src/ffi/c_str.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 75338e492ee..227799a352a 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -660,6 +660,19 @@ impl CStr { } } +#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")] +impl PartialEq<&Self> for CStr { + #[inline] + fn eq(&self, other: &&Self) -> bool { + *self == **other + } + + #[inline] + fn ne(&self, other: &&Self) -> bool { + *self != **other + } +} + // `.to_bytes()` representations are compared instead of the inner `[c_char]`s, // because `c_char` is `i8` (not `u8`) on some platforms. // That is why this is implemented manually and not derived. @@ -670,6 +683,7 @@ impl PartialOrd for CStr { self.to_bytes().partial_cmp(&other.to_bytes()) } } + #[stable(feature = "rust1", since = "1.0.0")] impl Ord for CStr { #[inline] |
