Use impl for AsRef trait bounds

This commit is contained in:
Marijn Suijten 2021-09-21 23:49:26 +02:00
parent 0e435578b7
commit 669bf52291
6 changed files with 19 additions and 19 deletions

View file

@ -126,7 +126,7 @@ impl AudioConverterConfig {
.unwrap_or(crate::AudioResamplerMethod::BlackmanNuttall)
}
pub fn set_mix_matrix<T: AsRef<[f32]>>(&mut self, v: &[T]) {
pub fn set_mix_matrix(&mut self, v: &[impl AsRef<[f32]>]) {
let length = v.get(0).map(|v| v.as_ref().len()).unwrap_or(0);
let array = gst::Array::from_owned(
v.iter()

View file

@ -5,9 +5,9 @@ use glib::translate::*;
use std::mem;
#[doc(alias = "gst_type_find_helper_for_data")]
pub fn type_find_helper_for_data<P: IsA<gst::Object>, R: AsRef<[u8]>>(
obj: Option<&P>,
data: R,
pub fn type_find_helper_for_data(
obj: Option<&impl IsA<gst::Object>>,
data: impl AsRef<[u8]>,
) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> {
assert_initialized_main_thread!();
unsafe {
@ -31,9 +31,9 @@ pub fn type_find_helper_for_data<P: IsA<gst::Object>, R: AsRef<[u8]>>(
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
#[doc(alias = "gst_type_find_helper_for_data_with_extension")]
pub fn type_find_helper_for_data_with_extension<P: IsA<gst::Object>, R: AsRef<[u8]>>(
obj: Option<&P>,
data: R,
pub fn type_find_helper_for_data_with_extension(
obj: Option<&impl IsA<gst::Object>>,
data: impl AsRef<[u8]>,
extension: Option<&str>,
) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> {
assert_initialized_main_thread!();

View file

@ -197,7 +197,7 @@ impl Harness {
}
#[doc(alias = "gst_harness_dump_to_file")]
pub fn dump_to_file<P: AsRef<path::Path>>(&mut self, filename: P) {
pub fn dump_to_file(&mut self, filename: impl AsRef<path::Path>) {
let filename = filename.as_ref();
unsafe {
ffi::gst_harness_dump_to_file(self.0.as_ptr(), filename.to_glib_none().0);

View file

@ -44,15 +44,15 @@ pub trait GstBinExtManual: 'static {
fn children(&self) -> Vec<Element>;
fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString;
fn debug_to_dot_file<Q: AsRef<path::Path>>(
fn debug_to_dot_file(
&self,
details: crate::DebugGraphDetails,
file_name: Q,
file_name: impl AsRef<path::Path>,
);
fn debug_to_dot_file_with_ts<Q: AsRef<path::Path>>(
fn debug_to_dot_file_with_ts(
&self,
details: crate::DebugGraphDetails,
file_name: Q,
file_name: impl AsRef<path::Path>,
);
fn set_bin_flags(&self, flags: BinFlags);
@ -166,18 +166,18 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
crate::debug_bin_to_dot_data(self, details)
}
fn debug_to_dot_file<Q: AsRef<path::Path>>(
fn debug_to_dot_file(
&self,
details: crate::DebugGraphDetails,
file_name: Q,
file_name: impl AsRef<path::Path>,
) {
crate::debug_bin_to_dot_file(self, details, file_name)
}
fn debug_to_dot_file_with_ts<Q: AsRef<path::Path>>(
fn debug_to_dot_file_with_ts(
&self,
details: crate::DebugGraphDetails,
file_name: Q,
file_name: impl AsRef<path::Path>,
) {
crate::debug_bin_to_dot_file_with_ts(self, details, file_name)
}

View file

@ -74,7 +74,7 @@ impl StreamCollectionBuilder {
self
}
pub fn streams<S: AsRef<Stream>>(self, streams: &[S]) -> Self {
pub fn streams(self, streams: &[impl AsRef<Stream>]) -> Self {
for stream in streams {
unsafe {
ffi::gst_stream_collection_add_stream(

View file

@ -634,7 +634,7 @@ impl<'a> Array<'a> {
Array(values.iter().map(|v| v.to_send_value()).collect())
}
pub fn from_borrowed<T: AsRef<[glib::SendValue]>>(values: &'a T) -> Self {
pub fn from_borrowed(values: &'a impl AsRef<[glib::SendValue]>) -> Self {
assert_initialized_main_thread!();
Array(Cow::Borrowed(values.as_ref()))
@ -728,7 +728,7 @@ impl<'a> List<'a> {
List(values.iter().map(|v| v.to_send_value()).collect())
}
pub fn from_borrowed<T: AsRef<[glib::SendValue]>>(values: &'a T) -> Self {
pub fn from_borrowed(values: &'a impl AsRef<[glib::SendValue]>) -> Self {
assert_initialized_main_thread!();
List(Cow::Borrowed(values.as_ref()))