@@ -50,19 +50,17 @@ impl fmt::Display for AllocError {
50
50
51
51
/// (Non-Null) Pointer and coallocation metadata.
52
52
#[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
53
- #[ allow( missing_debug_implementations) ]
54
- #[ derive( Clone , Copy ) ]
55
- pub struct PtrAndMeta < M : Clone + Copy > {
53
+ #[ derive( Clone , Copy , Debug ) ]
54
+ pub struct PtrAndMeta < M : CoAllocMetaBase > {
56
55
pub ptr : NonNull < u8 > ,
57
56
pub meta : M ,
58
57
}
59
58
60
59
/// (NonNull) Slice and coallocation metadata.
61
60
#[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
62
- #[ allow( missing_debug_implementations) ]
63
- #[ derive( Clone , Copy ) ]
61
+ #[ derive( Clone , Copy , Debug ) ]
64
62
/// Used for results (from `CoAllocator`'s functions, where applicable).
65
- pub struct SliceAndMeta < M : Clone + Copy > {
63
+ pub struct SliceAndMeta < M : CoAllocMetaBase > {
66
64
pub slice : NonNull < [ u8 ] > ,
67
65
pub meta : M ,
68
66
}
@@ -78,7 +76,6 @@ macro_rules! SHORT_TERM_VEC_PREFERS_COOP {
78
76
79
77
/// `Result` of `SliceAndMeta` or `AllocError`.
80
78
#[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
81
- #[ allow( missing_debug_implementations) ]
82
79
pub type SliceAndMetaResult < M > = Result < SliceAndMeta < M > , AllocError > ;
83
80
84
81
// @FIXME REMOVE
@@ -158,9 +155,11 @@ pub unsafe trait Allocator {
158
155
// It applies to the global (default) allocator only. And/or System allocator?! @FIXME
159
156
const CO_ALLOCATES_WITH_META : bool = false ;
160
157
158
+ /// NOT for public use. The default value MAY be REMOVED or CHANGED.
159
+ ///
161
160
/// @FIXME Validate (preferrable at compile time, otherwise as a test) that this type's
162
161
/// alignment <= `usize` alignment.
163
- type CoAllocMeta : Clone + Copy = ( ) ;
162
+ type CoAllocMeta : CoAllocMetaBase = CoAllocMetaPlain ;
164
163
165
164
/// Attempts to allocate a block of memory.
166
165
///
@@ -588,3 +587,24 @@ where
588
587
unsafe { ( * * self ) . shrink ( ptr, old_layout, new_layout) }
589
588
}
590
589
}
590
+
591
+ #[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
592
+ pub trait CoAllocMetaBase : Clone + Copy {
593
+ /// NOT for public use. This MAY BE REMOVED or CHANGED.
594
+ ///
595
+ /// For EXPERIMENTATION only.
596
+ fn new_plain ( ) -> Self ;
597
+ }
598
+
599
+ #[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
600
+ #[ derive( Clone , Copy , Debug ) ]
601
+ pub struct CoAllocMetaPlain { }
602
+
603
+ static CO_ALLOC_META_PLAIN : CoAllocMetaPlain = CoAllocMetaPlain { } ;
604
+
605
+ #[ unstable( feature = "global_co_alloc_meta" , issue = "none" ) ]
606
+ impl CoAllocMetaBase for CoAllocMetaPlain {
607
+ fn new_plain ( ) -> Self {
608
+ CO_ALLOC_META_PLAIN
609
+ }
610
+ }
0 commit comments