diff --git a/libosdp/src/pdinfo.rs b/libosdp/src/pdinfo.rs index cb4ba29..9c7505c 100644 --- a/libosdp/src/pdinfo.rs +++ b/libosdp/src/pdinfo.rs @@ -250,12 +250,11 @@ impl PdInfoBuilder { impl PdInfo { /// Get a C-repr struct for PdInfo that LibOSDP can operate on. pub fn as_struct(&mut self) -> libosdp_sys::osdp_pd_info_t { - let scbk; - if let Some(key) = self.scbk.as_mut() { - scbk = key.as_mut_ptr(); + let scbk = if let Some(key) = self.scbk { + Box::into_raw(Box::new(key)) as *mut _ } else { - scbk = std::ptr::null_mut::(); - } + std::ptr::null_mut::() + }; libosdp_sys::osdp_pd_info_t { name: self.name.as_ptr(), baud_rate: self.baud_rate,