@@ -8,7 +8,7 @@ use core::fmt::{self, Formatter, Debug, Display};
88use core:: hash:: { Hash , Hasher } ;
99use core:: marker:: PhantomData ;
1010
11- use crate :: { CollectorId , internals :: ConstCollectorId , GcSafe , GcRebrand , Gc } ;
11+ use crate :: { CollectorId , GcSafe , GcRebrand , Gc } ;
1212use zerogc_derive:: { Trace , unsafe_gc_impl} ;
1313
1414use self :: repr:: { GcArrayPtr } ;
@@ -64,29 +64,6 @@ impl<'gc, Id: CollectorId> GcString<'gc, Id> {
6464 unsafe { str:: from_utf8_unchecked ( self . as_bytes ( ) . as_slice ( ) ) }
6565 }
6666}
67- /// Const access to [GcString]
68- pub trait ConstStringAccess < ' gc > {
69- /// Get this string as a slice of bytes
70- fn as_bytes_const ( & self ) -> & ' gc [ u8 ] ;
71- /// Convert this string to a `str` slice
72- fn as_str_const ( & self ) -> & ' gc str ;
73- /// Get the length of this string (in bytes)
74- fn len_const ( & self ) -> usize ;
75- }
76- impl < ' gc , Id : ~const ConstCollectorId > const ConstStringAccess < ' gc > for GcString < ' gc , Id > {
77- #[ inline]
78- fn as_bytes_const ( & self ) -> & ' gc [ u8 ] {
79- self . bytes . as_slice_const ( )
80- }
81- #[ inline]
82- fn as_str_const ( & self ) -> & ' gc str {
83- unsafe { str:: from_utf8_unchecked ( self . as_bytes_const ( ) ) }
84- }
85- #[ inline]
86- fn len_const ( & self ) -> usize {
87- self . bytes . len_const ( )
88- }
89- }
9067impl < ' gc , Id : CollectorId > Deref for GcString < ' gc , Id > {
9168 type Target = str ;
9269 #[ inline]
@@ -180,59 +157,6 @@ unsafe impl<'gc, T, Id> Sync for GcArray<'gc, T, Id>
180157 where T : Sync , Id : CollectorId + Sync { }
181158unsafe impl < ' gc , T , Id > Send for GcArray < ' gc , T , Id >
182159 where T : Sync , Id : CollectorId + Sync { }
183- /// Const access to [GcString]
184- pub trait ConstArrayAccess < ' gc , T > {
185- /// The value of the array as a slice
186- fn as_slice_const < ' a > ( & self ) -> & ' a [ T ] where ' gc : ' a ;
187- /// Load a raw pointer to the array's value
188- fn as_raw_ptr_const ( & self ) -> * mut T ;
189- /// The length of this array
190- fn len_const ( & self ) -> usize ;
191- }
192- // Relax T: GcSafe bound
193- impl < ' gc , T , Id : ~const ConstCollectorId > const ConstArrayAccess < ' gc , T > for GcArray < ' gc , T , Id > {
194- #[ inline]
195- fn as_slice_const < ' a > ( & self ) -> & ' a [ T ] where ' gc : ' a {
196- /*
197- * TODO: This is horrible, but currently nessicarry
198- * to do this in a const-fn context.
199- */
200- match Id :: ArrayPtr :: UNCHECKED_KIND {
201- repr:: ArrayPtrKind :: Fat => {
202- unsafe {
203- core:: mem:: transmute_copy :: <
204- Id :: ArrayPtr ,
205- & ' a [ T ]
206- > ( & self . ptr )
207- }
208- } ,
209- repr:: ArrayPtrKind :: Thin => {
210- unsafe {
211- let ptr = core:: mem:: transmute_copy :: <
212- Id :: ArrayPtr ,
213- NonNull < T >
214- > ( & self . ptr ) ;
215- & * core:: ptr:: slice_from_raw_parts (
216- ptr. as_ptr ( ) ,
217- Id :: resolve_array_len_const (
218- self
219- )
220- )
221- }
222- } ,
223- }
224- }
225- /// Load a raw pointer to the array's value
226- #[ inline]
227- fn as_raw_ptr_const ( & self ) -> * mut T {
228- self . as_slice_const ( ) . as_ptr ( ) as * mut T
229- }
230- /// Load the length of the array
231- #[ inline]
232- fn len_const ( & self ) -> usize {
233- self . as_slice_const ( ) . len ( )
234- }
235- }
236160impl < ' gc , T , I , Id : CollectorId > Index < I > for GcArray < ' gc , T , Id >
237161 where I : SliceIndex < [ T ] > {
238162 type Output = I :: Output ;
0 commit comments