From 974a689fd77f93e0a484e027eed0d4a1c5b7cccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 23 Jan 2017 21:17:36 +0200 Subject: [PATCH] Keep amount of unsafe code a bit smaller for the GstStream* stream IDs --- gst-plugin/src/streams.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/gst-plugin/src/streams.rs b/gst-plugin/src/streams.rs index a1a7a687..9dac5bcc 100644 --- a/gst-plugin/src/streams.rs +++ b/gst-plugin/src/streams.rs @@ -100,11 +100,8 @@ impl Stream { fn gst_stream_get_stream_id(collection: *mut c_void) -> *mut c_char; } - unsafe { - CStr::from_ptr(gst_stream_get_stream_id(self.0)) - .to_str() - .unwrap() - } + let cstr = unsafe { CStr::from_ptr(gst_stream_get_stream_id(self.0)) }; + cstr.to_str().unwrap() } pub fn get_tags(&self) -> Option { @@ -213,11 +210,8 @@ impl StreamCollection { fn gst_stream_collection_get_upstream_id(collection: *mut c_void) -> *mut c_char; } - unsafe { - CStr::from_ptr(gst_stream_collection_get_upstream_id(self.0)) - .to_str() - .unwrap() - } + let cstr = unsafe { CStr::from_ptr(gst_stream_collection_get_upstream_id(self.0)) }; + cstr.to_str().unwrap() } pub unsafe fn as_ptr(&self) -> *const c_void {