From a154e45cce79b0c2264c1e1cd37a3d1bf5bc6154 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Thu, 5 Jan 2023 17:29:14 -0500 Subject: Rust API: Lots and lots of clippy changes --- rust/src/databuffer.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'rust/src/databuffer.rs') diff --git a/rust/src/databuffer.rs b/rust/src/databuffer.rs index 65003711..e8bf32c9 100644 --- a/rust/src/databuffer.rs +++ b/rust/src/databuffer.rs @@ -27,7 +27,7 @@ impl DataBuffer { } pub fn get_data(&self) -> &[u8] { - if self.0 == ptr::null_mut() { + if self.0.is_null() { // TODO : Change the default value and remove this return &[]; } @@ -43,6 +43,10 @@ impl DataBuffer { unsafe { BNGetDataBufferLength(self.0) } } + pub fn is_empty(&self) -> bool { + unsafe { BNGetDataBufferLength(self.0) == 0 } + } + // pub fn new(data: ?, len: usize) -> Result { // let read_buffer = unsafe { BNCreateDataBuffer(data, len) }; // if read_buffer.is_null() { @@ -62,7 +66,7 @@ impl Default for DataBuffer { impl Drop for DataBuffer { fn drop(&mut self) { - if self.0 != ptr::null_mut() { + if !self.0.is_null() { unsafe { BNFreeDataBuffer(self.0); } -- cgit v1.3.1