From 8d0a0ee6b15c2ceb821a65bbc08f06d7068bcb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Jun 2018 11:55:13 +0300 Subject: [PATCH] Directly use byte-slice-cast on the mapped buffer No need to first get a byte slice from it anymore due to the buffer map implementing AsRef/AsMut for byte slices --- examples/src/bin/appsink.rs | 2 +- examples/src/bin/pad_probes.rs | 2 +- tutorials/src/bin/basic-tutorial-8.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index ed32a1758..bd03e396a 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -93,7 +93,7 @@ fn create_pipeline() -> Result { return gst::FlowReturn::Error; }; - let samples = if let Ok(samples) = map.as_slice().as_slice_of::() { + let samples = if let Ok(samples) = map.as_slice_of::() { samples } else { gst_element_error!( diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index b4ad02c75..a6a05db17 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -30,7 +30,7 @@ fn example_main() { if let Some(gst::PadProbeData::Buffer(ref buffer)) = probe_info.data { let map = buffer.map_readable().unwrap(); - let samples = if let Ok(samples) = map.as_slice().as_slice_of::() { + let samples = if let Ok(samples) = map.as_slice_of::() { samples } else { return gst::PadProbeReturn::Ok; diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 0b8a593b4..be655ec81 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -167,7 +167,7 @@ fn main() { let buffer = buffer.get_mut().unwrap(); { let mut samples = buffer.map_writable().unwrap(); - let samples = samples.as_mut_slice().as_mut_slice_of::().unwrap(); + let samples = samples.as_mut_slice_of::().unwrap(); // Generate some psychodelic waveforms data.c += data.d;