Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
- Added `DiskIo` and `DiskIo2` protocols.
- Added `HardDriveMediaDevicePath` and related types.
- Added `PartialOrd` and `Ord` to the traits derived by `Guid`.
- Added `TryFrom<core::ffi::CStr>` implementation for `CStr8`.

### Fixed

Expand Down
24 changes: 0 additions & 24 deletions src/data_types/strs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::chars::{Char16, Char8, NUL_16, NUL_8};
use core::ffi::CStr;
use core::fmt;
use core::iter::Iterator;
use core::marker::PhantomData;
Expand Down Expand Up @@ -58,11 +57,6 @@ pub enum FromStrWithBufError {
/// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are
/// guaranteed to be 8 bit long.
///
/// A [`CStr8`] can be constructed from a [`core::ffi::CStr`] via a `try_from` call:
/// ```ignore
/// let cstr8: &CStr8 = TryFrom::try_from(cstr).unwrap();
/// ```
///
/// For convenience, a [`CStr8`] is comparable with [`core::str`] and
/// `alloc::string::String` from the standard library through the trait [`EqStrUntilNul`].
#[repr(transparent)]
Expand Down Expand Up @@ -160,14 +154,6 @@ impl<StrType: AsRef<str>> EqStrUntilNul<StrType> for CStr8 {
}
}

impl<'a> TryFrom<&'a CStr> for &'a CStr8 {
type Error = FromSliceWithNulError;

fn try_from(cstr: &'a CStr) -> Result<Self, Self::Error> {
CStr8::from_bytes_with_nul(cstr.to_bytes_with_nul())
}
}

/// An UCS-2 null-terminated string.
///
/// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are
Expand Down Expand Up @@ -533,16 +519,6 @@ mod tests {
use crate::alloc_api::string::String;
use uefi_macros::{cstr16, cstr8};

// Tests if our CStr8 type can be constructed from a valid core::ffi::CStr
#[test]
fn test_cstr8_from_cstr() {
let msg = "hello world\0";
let cstr = unsafe { CStr::from_ptr(msg.as_ptr().cast()) };
let cstr8: &CStr8 = TryFrom::try_from(cstr).unwrap();
assert!(cstr8.eq_str_until_nul(&msg));
assert!(msg.eq_str_until_nul(cstr8));
}

#[test]
fn test_cstr16_num_bytes() {
let s = CStr16::from_u16_with_nul(&[65, 66, 67, 0]).unwrap();
Expand Down