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/user.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'rust/src/collaboration/user.rs') diff --git a/rust/src/collaboration/user.rs b/rust/src/collaboration/user.rs index 43b4e854..d4aea2c5 100644 --- a/rust/src/collaboration/user.rs +++ b/rust/src/collaboration/user.rs @@ -1,6 +1,5 @@ use super::Remote; use binaryninjacore_sys::*; -use std::ffi::c_char; use std::ptr::NonNull; use crate::rc::{CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; @@ -51,12 +50,8 @@ impl RemoteUser { /// Set user's username. You will need to push the user to update the Remote pub fn set_username(&self, username: U) -> Result<(), ()> { let username = username.to_cstr(); - let result = unsafe { - BNCollaborationUserSetUsername( - self.handle.as_ptr(), - username.as_ref().as_ptr() as *const c_char, - ) - }; + let result = + unsafe { BNCollaborationUserSetUsername(self.handle.as_ptr(), username.as_ptr()) }; if result { Ok(()) } else { @@ -74,12 +69,8 @@ impl RemoteUser { /// Set user's email. You will need to push the user to update the Remote pub fn set_email(&self, email: U) -> Result<(), ()> { let username = email.to_cstr(); - let result = unsafe { - BNCollaborationUserSetEmail( - self.handle.as_ptr(), - username.as_ref().as_ptr() as *const c_char, - ) - }; + let result = + unsafe { BNCollaborationUserSetEmail(self.handle.as_ptr(), username.as_ptr()) }; if result { Ok(()) } else { -- cgit v1.3.1