From 788a8b7091bbdde77817030e0836d7a7a786fd99 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:47:55 -0400 Subject: [Rust] Simplify usage surrounding c strings `cstring.as_ref().as_ptr() as *const c_char` -> `cstring.as_ptr()` `cstring.as_ref().as_ptr() as *mut _` -> `cstring.as_ptr()` `cstring.as_ptr() as *const c_char` -> `cstring.as_ptr()` With a few fixes for cstrings that might be dropped prematurely. --- rust/src/collaboration/folder.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'rust/src/collaboration/folder.rs') diff --git a/rust/src/collaboration/folder.rs b/rust/src/collaboration/folder.rs index 0fd2bf87..b5fde3b4 100644 --- a/rust/src/collaboration/folder.rs +++ b/rust/src/collaboration/folder.rs @@ -1,6 +1,5 @@ use super::{Remote, RemoteProject}; use binaryninjacore_sys::*; -use std::ffi::c_char; use std::ptr::NonNull; use crate::project::folder::ProjectFolder; @@ -106,12 +105,7 @@ impl RemoteFolder { /// Set the display name of the folder. You will need to push the folder to update the remote version. pub fn set_name(&self, name: S) -> Result<(), ()> { let name = name.to_cstr(); - let success = unsafe { - BNRemoteFolderSetName( - self.handle.as_ptr(), - name.as_ref().as_ptr() as *const c_char, - ) - }; + let success = unsafe { BNRemoteFolderSetName(self.handle.as_ptr(), name.as_ptr()) }; success.then_some(()).ok_or(()) } @@ -125,12 +119,8 @@ impl RemoteFolder { /// Set the description of the folder. You will need to push the folder to update the remote version. pub fn set_description(&self, description: S) -> Result<(), ()> { let description = description.to_cstr(); - let success = unsafe { - BNRemoteFolderSetDescription( - self.handle.as_ptr(), - description.as_ref().as_ptr() as *const c_char, - ) - }; + let success = + unsafe { BNRemoteFolderSetDescription(self.handle.as_ptr(), description.as_ptr()) }; success.then_some(()).ok_or(()) } } -- cgit v1.3.1