File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ use crate::alloc::{HugePageMemory, allocate_zeroed_vec};
1414pub trait Buf < T > :
1515 Default + Debug + Deref < Target = [ T ] > + DerefMut + Send + Sync + ' static + private:: Sealed
1616{
17+ /// The 'kind' of this Buf implementation. This is e.g. `Vec<E>` for `Vec<T>
18+ /// as Buf<T>`.
19+ ///
20+ /// This associated type can be used to create Bufs of the same kind, but
21+ /// with a different inner type.
22+ type BufKind < E > : Buf < E >
23+ where
24+ E : Zeroable + Clone + Default + Debug + Send + Sync + ' static ;
1725 /// Create a new `Buf` of length `len` with all elements set to zero.
1826 ///
1927 /// Implementations of this directly allocate zeroed memory and do not write
@@ -41,6 +49,11 @@ pub trait Buf<T>:
4149}
4250
4351impl < T : Zeroable + Clone + Default + Debug + Send + Sync + ' static > Buf < T > for Vec < T > {
52+ type BufKind < E >
53+ = Vec < E >
54+ where
55+ E : Zeroable + Clone + Default + Debug + Send + Sync + ' static ;
56+
4457 fn zeroed ( len : usize ) -> Self {
4558 allocate_zeroed_vec ( len)
4659 }
@@ -66,6 +79,11 @@ impl<T: Zeroable + Clone + Default + Debug + Send + Sync + 'static> Buf<T> for V
6679}
6780
6881impl < T : Zeroable + Clone + Default + Debug + Send + Sync + ' static > Buf < T > for HugePageMemory < T > {
82+ type BufKind < E >
83+ = HugePageMemory < E >
84+ where
85+ E : Zeroable + Clone + Default + Debug + Send + Sync + ' static ;
86+
6987 fn zeroed ( len : usize ) -> Self {
7088 HugePageMemory :: zeroed ( len)
7189 }
You can’t perform that action at this time.
0 commit comments