Move len() from TypedBuffer to Buffer

This commit is contained in:
PierreKrieger 2016-09-28 18:02:04 +02:00 committed by Pierre Krieger
parent 7d27103c15
commit 4990d78c12

View File

@ -30,6 +30,11 @@ pub unsafe trait Buffer {
self.inner().buffer.size()
}
#[inline]
fn len(&self) -> usize where Self: TypedBuffer, Self::Content: Content {
self.size() / <Self::Content as Content>::indiv_size()
}
#[inline]
fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self> where Self: Sized + TypedBuffer {
BufferSlice::from(self)
@ -193,11 +198,6 @@ unsafe impl<'a, B: ?Sized, S> TrackedBuffer<S> for &'a B where B: TrackedBuffer<
pub unsafe trait TypedBuffer: Buffer {
type Content: ?Sized + 'static;
#[inline]
fn len(&self) -> usize where Self::Content: Content {
self.size() / <Self::Content as Content>::indiv_size()
}
}
unsafe impl<B: ?Sized> TypedBuffer for Arc<B> where B: TypedBuffer {