Skip to content

Commit d10d911

Browse files
authored
Merge pull request #341 from hashgraph/sr/casts
refactor(rust): Replace some `as <pointer>` expressions with `cast*`
2 parents 4899036 + 34eb6e5 commit d10d911

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

sdk/rust/src/ffi/contract_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ContractId {
3333
let crate::ContractId { shard, realm, num, evm_address } = rust;
3434

3535
let evm_address =
36-
evm_address.map(|it| NonNull::new(Box::into_raw(Box::new(it)) as *mut u8).unwrap());
36+
evm_address.map(|it| NonNull::new(Box::into_raw(Box::new(it)).cast::<u8>()).unwrap());
3737

3838
Self { shard, realm, num, evm_address }
3939
}

sdk/rust/src/ffi/execute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub unsafe extern "C" fn hedera_execute(
119119
};
120120

121121
let response =
122-
response.map(|response| CString::new(response).unwrap().into_raw() as *const c_char);
122+
response.map(|response| CString::new(response).unwrap().into_raw().cast_const());
123123

124124
let (err, response) = match response {
125125
Ok(response) => (Error::Ok, response),
@@ -129,7 +129,7 @@ pub unsafe extern "C" fn hedera_execute(
129129
callback.call(err, response);
130130

131131
if !response.is_null() {
132-
drop(unsafe { CString::from_raw(response as *mut _) });
132+
drop(unsafe { CString::from_raw(response.cast_mut()) });
133133
}
134134
});
135135

sdk/rust/src/ffi/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl CSigner {
130130
let signature_out = unsafe { slice::from_raw_parts(signature, signature_size) }.to_vec();
131131

132132
unsafe {
133-
(self.free_signature_func)(self.context, signature as *mut u8, signature_size);
133+
(self.free_signature_func)(self.context, signature.cast_mut(), signature_size);
134134
}
135135

136136
(self.public_key, signature_out)

0 commit comments

Comments
 (0)