Skip to content

Commit 5f4e158

Browse files
Temporarily revert use of core::ffi::CStr
The move of `CStr` from `std` to `core` is not due to become stable until 1.64. The first nightly where it could be used without the unstable `core_c_str` feature was 2022-07-16, which is still pretty recent. Let's back this change out for now to give users pinned to older versions more time.
1 parent d64fdb0 commit 5f4e158

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
- Added `DiskIo` and `DiskIo2` protocols.
2828
- Added `HardDriveMediaDevicePath` and related types.
2929
- Added `PartialOrd` and `Ord` to the traits derived by `Guid`.
30-
- Added `TryFrom<core::ffi::CStr>` implementation for `CStr8`.
3130

3231
### Fixed
3332

src/data_types/strs.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::chars::{Char16, Char8, NUL_16, NUL_8};
2-
use core::ffi::CStr;
32
use core::fmt;
43
use core::iter::Iterator;
54
use core::marker::PhantomData;
@@ -58,11 +57,6 @@ pub enum FromStrWithBufError {
5857
/// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are
5958
/// guaranteed to be 8 bit long.
6059
///
61-
/// A [`CStr8`] can be constructed from a [`core::ffi::CStr`] via a `try_from` call:
62-
/// ```ignore
63-
/// let cstr8: &CStr8 = TryFrom::try_from(cstr).unwrap();
64-
/// ```
65-
///
6660
/// For convenience, a [`CStr8`] is comparable with [`core::str`] and
6761
/// `alloc::string::String` from the standard library through the trait [`EqStrUntilNul`].
6862
#[repr(transparent)]
@@ -160,14 +154,6 @@ impl<StrType: AsRef<str>> EqStrUntilNul<StrType> for CStr8 {
160154
}
161155
}
162156

163-
impl<'a> TryFrom<&'a CStr> for &'a CStr8 {
164-
type Error = FromSliceWithNulError;
165-
166-
fn try_from(cstr: &'a CStr) -> Result<Self, Self::Error> {
167-
CStr8::from_bytes_with_nul(cstr.to_bytes_with_nul())
168-
}
169-
}
170-
171157
/// An UCS-2 null-terminated string.
172158
///
173159
/// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are
@@ -533,16 +519,6 @@ mod tests {
533519
use crate::alloc_api::string::String;
534520
use uefi_macros::{cstr16, cstr8};
535521

536-
// Tests if our CStr8 type can be constructed from a valid core::ffi::CStr
537-
#[test]
538-
fn test_cstr8_from_cstr() {
539-
let msg = "hello world\0";
540-
let cstr = unsafe { CStr::from_ptr(msg.as_ptr().cast()) };
541-
let cstr8: &CStr8 = TryFrom::try_from(cstr).unwrap();
542-
assert!(cstr8.eq_str_until_nul(&msg));
543-
assert!(msg.eq_str_until_nul(cstr8));
544-
}
545-
546522
#[test]
547523
fn test_cstr16_num_bytes() {
548524
let s = CStr16::from_u16_with_nul(&[65, 66, 67, 0]).unwrap();

0 commit comments

Comments
 (0)