From 9dadf92c16da5cd21def79ae39ca98803c9208ec Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 5 May 2025 13:17:30 -0400 Subject: [Rust] Rename `AsCStr` to `IntoCStr` --- rust/src/string.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'rust/src/string.rs') diff --git a/rust/src/string.rs b/rust/src/string.rs index 820418d0..a670320b 100644 --- a/rust/src/string.rs +++ b/rust/src/string.rs @@ -62,7 +62,7 @@ pub struct BnString { } impl BnString { - pub fn new(s: S) -> Self { + pub fn new(s: S) -> Self { use binaryninjacore_sys::BNAllocString; let raw = s.to_cstr(); unsafe { Self::from_raw(BNAllocString(raw.as_ptr())) } @@ -183,13 +183,13 @@ unsafe impl CoreArrayProviderInner for BnString { } } -pub unsafe trait AsCStr { +pub unsafe trait IntoCStr { type Result: Deref; fn to_cstr(self) -> Self::Result; } -unsafe impl AsCStr for &CStr { +unsafe impl IntoCStr for &CStr { type Result = Self; fn to_cstr(self) -> Self::Result { @@ -197,7 +197,7 @@ unsafe impl AsCStr for &CStr { } } -unsafe impl AsCStr for BnString { +unsafe impl IntoCStr for BnString { type Result = Self; fn to_cstr(self) -> Self::Result { @@ -205,7 +205,7 @@ unsafe impl AsCStr for BnString { } } -unsafe impl AsCStr for &BnString { +unsafe impl IntoCStr for &BnString { type Result = BnString; fn to_cstr(self) -> Self::Result { @@ -213,7 +213,7 @@ unsafe impl AsCStr for &BnString { } } -unsafe impl AsCStr for CString { +unsafe impl IntoCStr for CString { type Result = Self; fn to_cstr(self) -> Self::Result { @@ -221,7 +221,7 @@ unsafe impl AsCStr for CString { } } -unsafe impl AsCStr for &str { +unsafe impl IntoCStr for &str { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -229,7 +229,7 @@ unsafe impl AsCStr for &str { } } -unsafe impl AsCStr for String { +unsafe impl IntoCStr for String { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -237,7 +237,7 @@ unsafe impl AsCStr for String { } } -unsafe impl AsCStr for &String { +unsafe impl IntoCStr for &String { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -245,7 +245,7 @@ unsafe impl AsCStr for &String { } } -unsafe impl<'a> AsCStr for &'a Cow<'a, str> { +unsafe impl<'a> IntoCStr for &'a Cow<'a, str> { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -253,7 +253,7 @@ unsafe impl<'a> AsCStr for &'a Cow<'a, str> { } } -unsafe impl AsCStr for Cow<'_, str> { +unsafe impl IntoCStr for Cow<'_, str> { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -261,7 +261,7 @@ unsafe impl AsCStr for Cow<'_, str> { } } -unsafe impl AsCStr for &QualifiedName { +unsafe impl IntoCStr for &QualifiedName { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -269,7 +269,7 @@ unsafe impl AsCStr for &QualifiedName { } } -unsafe impl AsCStr for PathBuf { +unsafe impl IntoCStr for PathBuf { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -277,7 +277,7 @@ unsafe impl AsCStr for PathBuf { } } -unsafe impl AsCStr for &Path { +unsafe impl IntoCStr for &Path { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -286,7 +286,7 @@ unsafe impl AsCStr for &Path { } } -unsafe impl AsCStr for TypeArchiveSnapshotId { +unsafe impl IntoCStr for TypeArchiveSnapshotId { type Result = CString; fn to_cstr(self) -> Self::Result { @@ -295,12 +295,12 @@ unsafe impl AsCStr for TypeArchiveSnapshotId { } pub trait IntoJson { - type Output: AsCStr; + type Output: IntoCStr; fn get_json_string(self) -> Result; } -impl IntoJson for S { +impl IntoJson for S { type Output = S; fn get_json_string(self) -> Result { -- cgit v1.3.1