diff --git a/objc2/src/declare.rs b/objc2/src/declare.rs index f7236db1a..db670d8d8 100644 --- a/objc2/src/declare.rs +++ b/objc2/src/declare.rs @@ -115,7 +115,6 @@ mod ivar; mod ivar_forwarding_impls; use alloc::format; -use alloc::string::ToString; use core::mem; use core::mem::ManuallyDrop; use core::ptr; @@ -409,7 +408,7 @@ impl ClassBuilder { /// happens if there already was an ivar with that name. pub fn add_ivar(&mut self, name: &str) { let c_name = CString::new(name).unwrap(); - let encoding = CString::new(T::ENCODING.to_string()).unwrap(); + let encoding = T::ENCODING_CSTR; let size = mem::size_of::(); let align = log2_align_of::(); let success = Bool::from_raw(unsafe { diff --git a/objc2/src/foundation/value.rs b/objc2/src/foundation/value.rs index 670c96bd8..5e7d5987a 100644 --- a/objc2/src/foundation/value.rs +++ b/objc2/src/foundation/value.rs @@ -1,11 +1,10 @@ -use alloc::string::ToString; use core::ffi::c_void; use core::fmt; use core::hash; use core::mem::MaybeUninit; use core::ptr::NonNull; use core::str; -use std::ffi::{CStr, CString}; +use std::ffi::CStr; use std::os::raw::c_char; use super::{NSCopying, NSObject, NSPoint, NSRange, NSRect, NSSize}; @@ -65,7 +64,7 @@ impl NSValue { pub fn new(value: T) -> Id { let bytes: *const T = &value; let bytes: *const c_void = bytes.cast(); - let encoding = CString::new(T::ENCODING.to_string()).unwrap(); + let encoding = T::ENCODING_CSTR; unsafe { msg_send_id![ msg_send_id![Self::class(), alloc],