|
1 | 1 | use super::chars::{Char16, Char8, NUL_16, NUL_8}; |
2 | | -use core::ffi::CStr; |
3 | 2 | use core::fmt; |
4 | 3 | use core::iter::Iterator; |
5 | 4 | use core::marker::PhantomData; |
@@ -58,11 +57,6 @@ pub enum FromStrWithBufError { |
58 | 57 | /// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are |
59 | 58 | /// guaranteed to be 8 bit long. |
60 | 59 | /// |
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 | | -/// |
66 | 60 | /// For convenience, a [`CStr8`] is comparable with [`core::str`] and |
67 | 61 | /// `alloc::string::String` from the standard library through the trait [`EqStrUntilNul`]. |
68 | 62 | #[repr(transparent)] |
@@ -160,14 +154,6 @@ impl<StrType: AsRef<str>> EqStrUntilNul<StrType> for CStr8 { |
160 | 154 | } |
161 | 155 | } |
162 | 156 |
|
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 | | - |
171 | 157 | /// An UCS-2 null-terminated string. |
172 | 158 | /// |
173 | 159 | /// This type is largely inspired by [`core::ffi::CStr`] with the exception that all characters are |
@@ -533,16 +519,6 @@ mod tests { |
533 | 519 | use crate::alloc_api::string::String; |
534 | 520 | use uefi_macros::{cstr16, cstr8}; |
535 | 521 |
|
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 | | - |
546 | 522 | #[test] |
547 | 523 | fn test_cstr16_num_bytes() { |
548 | 524 | let s = CStr16::from_u16_with_nul(&[65, 66, 67, 0]).unwrap(); |
|
0 commit comments