mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-11 18:56:33 +00:00
Also implement Deref/DerefMut for MappedBuffer for &[u8]
This commit is contained in:
parent
85fdc8bf13
commit
5dff6026be
1 changed files with 15 additions and 0 deletions
|
@ -10,6 +10,7 @@ use std::ptr;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
use std::ops;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use std::usize;
|
use std::usize;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
@ -479,6 +480,20 @@ impl AsMut<[u8]> for MappedBuffer<Writable> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> ops::Deref for MappedBuffer<T> {
|
||||||
|
type Target = [u8];
|
||||||
|
|
||||||
|
fn deref(&self) -> &[u8] {
|
||||||
|
self.as_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for MappedBuffer<Writable> {
|
||||||
|
fn deref_mut(&mut self) -> &mut [u8] {
|
||||||
|
self.as_mut_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Drop for MappedBuffer<T> {
|
impl<T> Drop for MappedBuffer<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Some(ref buffer) = self.buffer {
|
if let Some(ref buffer) = self.buffer {
|
||||||
|
|
Loading…
Reference in a new issue