From 380fb319bab4dd6ce1960a924fc91d3ba564d6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Sep 2017 11:40:32 +0300 Subject: [PATCH] Don't return &'static references from functions but give them a generic lifetime https://github.com/rust-lang/rust/pull/42417#issue-233404573 --- gstreamer-audio/src/audio_format.rs | 2 +- gstreamer-audio/src/audio_format_info.rs | 6 +++--- gstreamer-video/src/video_format.rs | 2 +- gstreamer-video/src/video_format_info.rs | 4 ++-- gstreamer/src/device_provider.rs | 4 ++-- gstreamer/src/element.rs | 4 ++-- gstreamer/src/tags.rs | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gstreamer-audio/src/audio_format.rs b/gstreamer-audio/src/audio_format.rs index 7702030d9..6b2032d6b 100644 --- a/gstreamer-audio/src/audio_format.rs +++ b/gstreamer-audio/src/audio_format.rs @@ -39,7 +39,7 @@ impl ::AudioFormat { unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) } } - pub fn to_string(&self) -> &'static str { + pub fn to_string<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib())) .to_str() diff --git a/gstreamer-audio/src/audio_format_info.rs b/gstreamer-audio/src/audio_format_info.rs index fd47a4e07..cfb5e0844 100644 --- a/gstreamer-audio/src/audio_format_info.rs +++ b/gstreamer-audio/src/audio_format_info.rs @@ -66,11 +66,11 @@ impl AudioFormatInfo { from_glib(self.0.format) } - pub fn name(&self) -> &'static str { + pub fn name<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() } } - pub fn description(&self) -> &'static str { + pub fn description<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() } } @@ -94,7 +94,7 @@ impl AudioFormatInfo { from_glib(self.0.unpack_format) } - pub fn silence(&self) -> &'static [u8] { + pub fn silence<'a>(&self) -> &'a [u8] { &self.0.silence } diff --git a/gstreamer-video/src/video_format.rs b/gstreamer-video/src/video_format.rs index 37b85764c..bb630c106 100644 --- a/gstreamer-video/src/video_format.rs +++ b/gstreamer-video/src/video_format.rs @@ -82,7 +82,7 @@ impl ::VideoFormat { } } - pub fn to_string(&self) -> &'static str { + pub fn to_string<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(ffi::gst_video_format_to_string(self.to_glib())) .to_str() diff --git a/gstreamer-video/src/video_format_info.rs b/gstreamer-video/src/video_format_info.rs index 03b86196c..4c8cd890d 100644 --- a/gstreamer-video/src/video_format_info.rs +++ b/gstreamer-video/src/video_format_info.rs @@ -33,11 +33,11 @@ impl VideoFormatInfo { from_glib(self.0.format) } - pub fn name(&self) -> &'static str { + pub fn name<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() } } - pub fn description(&self) -> &'static str { + pub fn description<'a>(&self) -> &'a str { unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() } } diff --git a/gstreamer/src/device_provider.rs b/gstreamer/src/device_provider.rs index b5248ae38..fbdd59735 100644 --- a/gstreamer/src/device_provider.rs +++ b/gstreamer/src/device_provider.rs @@ -17,11 +17,11 @@ use ffi; use gobject_ffi; pub trait DeviceProviderExtManual { - fn get_metadata(&self, key: &str) -> Option<&'static str>; + fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>; } impl> DeviceProviderExtManual for O { - fn get_metadata(&self, key: &str) -> Option<&'static str> { + fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as *mut ffi::GstDeviceProviderClass; diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 154795872..c560f9d2a 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -54,7 +54,7 @@ pub trait ElementExtManual { fn send_event(&self, event: Event) -> bool; - fn get_metadata(&self, key: &str) -> Option<&'static str>; + fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>; fn get_pad_template(&self, name: &str) -> Option; fn get_pad_template_list(&self) -> Vec; @@ -79,7 +79,7 @@ impl> ElementExtManual for O { } } - fn get_metadata(&self, key: &str) -> Option<&'static str> { + fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> { unsafe { let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as *mut ffi::GstElementClass; diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 10ac8d5d7..b831e63e8 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -24,7 +24,7 @@ use Sample; pub trait Tag<'a> { type TagType: FromValueOptional<'a> + SetValue; - fn tag_name() -> &'static str; + fn tag_name<'b>() -> &'b str; } macro_rules! impl_tag( @@ -32,7 +32,7 @@ macro_rules! impl_tag( pub struct $name; impl<'a> Tag<'a> for $name { type TagType = $t; - fn tag_name() -> &'static str { + fn tag_name<'b>() -> &'b str { $tag } }