Skip to content

Commit 380fb31

Browse files
committed
Don't return &'static references from functions but give them a generic lifetime
rust-lang/rust#42417 (comment)
1 parent 15d05ed commit 380fb31

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

gstreamer-audio/src/audio_format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl ::AudioFormat {
3939
unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) }
4040
}
4141

42-
pub fn to_string(&self) -> &'static str {
42+
pub fn to_string<'a>(&self) -> &'a str {
4343
unsafe {
4444
CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib()))
4545
.to_str()

gstreamer-audio/src/audio_format_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ impl AudioFormatInfo {
6666
from_glib(self.0.format)
6767
}
6868

69-
pub fn name(&self) -> &'static str {
69+
pub fn name<'a>(&self) -> &'a str {
7070
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
7171
}
7272

73-
pub fn description(&self) -> &'static str {
73+
pub fn description<'a>(&self) -> &'a str {
7474
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
7575
}
7676

@@ -94,7 +94,7 @@ impl AudioFormatInfo {
9494
from_glib(self.0.unpack_format)
9595
}
9696

97-
pub fn silence(&self) -> &'static [u8] {
97+
pub fn silence<'a>(&self) -> &'a [u8] {
9898
&self.0.silence
9999
}
100100

gstreamer-video/src/video_format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl ::VideoFormat {
8282
}
8383
}
8484

85-
pub fn to_string(&self) -> &'static str {
85+
pub fn to_string<'a>(&self) -> &'a str {
8686
unsafe {
8787
CStr::from_ptr(ffi::gst_video_format_to_string(self.to_glib()))
8888
.to_str()

gstreamer-video/src/video_format_info.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ impl VideoFormatInfo {
3333
from_glib(self.0.format)
3434
}
3535

36-
pub fn name(&self) -> &'static str {
36+
pub fn name<'a>(&self) -> &'a str {
3737
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
3838
}
3939

40-
pub fn description(&self) -> &'static str {
40+
pub fn description<'a>(&self) -> &'a str {
4141
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
4242
}
4343

gstreamer/src/device_provider.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use ffi;
1717
use gobject_ffi;
1818

1919
pub trait DeviceProviderExtManual {
20-
fn get_metadata(&self, key: &str) -> Option<&'static str>;
20+
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
2121
}
2222

2323
impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
24-
fn get_metadata(&self, key: &str) -> Option<&'static str> {
24+
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
2525
unsafe {
2626
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as
2727
*mut ffi::GstDeviceProviderClass;

gstreamer/src/element.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait ElementExtManual {
5454

5555
fn send_event(&self, event: Event) -> bool;
5656

57-
fn get_metadata(&self, key: &str) -> Option<&'static str>;
57+
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
5858

5959
fn get_pad_template(&self, name: &str) -> Option<PadTemplate>;
6060
fn get_pad_template_list(&self) -> Vec<PadTemplate>;
@@ -79,7 +79,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
7979
}
8080
}
8181

82-
fn get_metadata(&self, key: &str) -> Option<&'static str> {
82+
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
8383
unsafe {
8484
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class as
8585
*mut ffi::GstElementClass;

gstreamer/src/tags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ use Sample;
2424

2525
pub trait Tag<'a> {
2626
type TagType: FromValueOptional<'a> + SetValue;
27-
fn tag_name() -> &'static str;
27+
fn tag_name<'b>() -> &'b str;
2828
}
2929

3030
macro_rules! impl_tag(
3131
($name:ident, $t:ty, $tag:expr) => {
3232
pub struct $name;
3333
impl<'a> Tag<'a> for $name {
3434
type TagType = $t;
35-
fn tag_name() -> &'static str {
35+
fn tag_name<'b>() -> &'b str {
3636
$tag
3737
}
3838
}

0 commit comments

Comments
 (0)