@@ -158,7 +158,7 @@ pub enum Tag {
158
158
}
159
159
160
160
/// Helper enum to split this raw byte string into its possible representation.
161
- pub enum RawSplit < ' a , ' borrow , B : Backend > {
161
+ pub enum Split < ' a , ' borrow , B : Backend > {
162
162
/// Inline representation
163
163
Inline ( & ' a Inline ) ,
164
164
/// Allocated and shared representation
@@ -168,7 +168,7 @@ pub enum RawSplit<'a, 'borrow, B: Backend> {
168
168
}
169
169
170
170
/// Helper enum to split this raw byte string into its possible representation mutably.
171
- pub enum RawSplitMut < ' a , ' borrow , B : Backend > {
171
+ pub enum SplitMut < ' a , ' borrow , B : Backend > {
172
172
/// Inline representation
173
173
Inline ( & ' a mut Inline ) ,
174
174
/// Allocated and shared representation
@@ -239,42 +239,42 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
239
239
240
240
/// Splits this raw into its possible representation.
241
241
#[ inline]
242
- pub ( super ) const fn split ( & self ) -> RawSplit < ' _ , ' borrow , B > {
242
+ pub ( super ) const fn split ( & self ) -> Split < ' _ , ' borrow , B > {
243
243
let tag = self . tag ( ) ;
244
244
let union = self . union ( ) ;
245
245
match tag {
246
246
Tag :: Inline => {
247
247
// SAFETY: representation checked
248
- RawSplit :: Inline ( unsafe { & union. inline } )
248
+ Split :: Inline ( unsafe { & union. inline } )
249
249
}
250
250
Tag :: Borrowed => {
251
251
// SAFETY: representation checked
252
- RawSplit :: Borrowed ( unsafe { & union. borrowed } )
252
+ Split :: Borrowed ( unsafe { & union. borrowed } )
253
253
}
254
254
Tag :: Allocated => {
255
255
// SAFETY: representation checked
256
- RawSplit :: Allocated ( unsafe { & union. allocated } )
256
+ Split :: Allocated ( unsafe { & union. allocated } )
257
257
}
258
258
}
259
259
}
260
260
261
261
/// Splits this raw into its possible representation.
262
262
#[ inline]
263
- pub ( super ) fn split_mut ( & mut self ) -> RawSplitMut < ' _ , ' borrow , B > {
263
+ pub ( super ) fn split_mut ( & mut self ) -> SplitMut < ' _ , ' borrow , B > {
264
264
let tag = self . tag ( ) ;
265
265
let union = self . union_mut ( ) ;
266
266
match tag {
267
267
Tag :: Inline => {
268
268
// SAFETY: representation checked
269
- RawSplitMut :: Inline ( unsafe { & mut union. inline } )
269
+ SplitMut :: Inline ( unsafe { & mut union. inline } )
270
270
}
271
271
Tag :: Borrowed => {
272
272
// SAFETY: representation checked
273
- RawSplitMut :: Borrowed ( unsafe { & mut union. borrowed } )
273
+ SplitMut :: Borrowed ( unsafe { & mut union. borrowed } )
274
274
}
275
275
Tag :: Allocated => {
276
276
// SAFETY: representation checked
277
- RawSplitMut :: Allocated ( unsafe { & mut union. allocated } )
277
+ SplitMut :: Allocated ( unsafe { & mut union. allocated } )
278
278
}
279
279
}
280
280
}
@@ -296,7 +296,7 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
296
296
/// # Safety
297
297
///
298
298
/// The input slice's length MUST be at most `INLINE_CAPACITY`.
299
- pub ( super ) unsafe fn inline_unchecked ( bytes : & [ u8 ] ) -> Self {
299
+ pub ( super ) const unsafe fn inline_unchecked ( bytes : & [ u8 ] ) -> Self {
300
300
// SAFETY: see function precondition
301
301
let inline = unsafe { Inline :: new_unchecked ( bytes) } ;
302
302
Self :: from_inline ( inline)
@@ -349,9 +349,9 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
349
349
#[ must_use]
350
350
pub const fn as_slice ( & self ) -> & [ u8 ] {
351
351
match self . split ( ) {
352
- RawSplit :: Inline ( inline) => inline. as_slice ( ) ,
353
- RawSplit :: Allocated ( heap) => heap. as_slice ( ) ,
354
- RawSplit :: Borrowed ( borrowed) => borrowed. as_slice ( ) ,
352
+ Split :: Inline ( inline) => inline. as_slice ( ) ,
353
+ Split :: Allocated ( heap) => heap. as_slice ( ) ,
354
+ Split :: Borrowed ( borrowed) => borrowed. as_slice ( ) ,
355
355
}
356
356
}
357
357
@@ -360,9 +360,9 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
360
360
#[ must_use]
361
361
pub const fn as_ptr ( & self ) -> * const u8 {
362
362
match self . split ( ) {
363
- RawSplit :: Inline ( inline) => inline. as_ptr ( ) ,
364
- RawSplit :: Allocated ( heap) => heap. as_ptr ( ) ,
365
- RawSplit :: Borrowed ( borrowed) => borrowed. as_ptr ( ) ,
363
+ Split :: Inline ( inline) => inline. as_ptr ( ) ,
364
+ Split :: Allocated ( heap) => heap. as_ptr ( ) ,
365
+ Split :: Borrowed ( borrowed) => borrowed. as_ptr ( ) ,
366
366
}
367
367
}
368
368
@@ -379,13 +379,13 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
379
379
debug_assert ! ( range. end <= self . len( ) ) ;
380
380
381
381
let result = match self . split ( ) {
382
- RawSplit :: Inline ( inline) => {
382
+ Split :: Inline ( inline) => {
383
383
// SAFETY: by `slice_unchecked` safety precondition and `split`
384
384
// range must be of a length <= self.len() <= `INLINE_CAPACITY`
385
385
unsafe { Self :: inline_unchecked ( & inline. as_slice ( ) [ range] ) }
386
386
}
387
- RawSplit :: Borrowed ( borrowed) => Self :: borrowed ( & borrowed. as_slice ( ) [ range] ) ,
388
- RawSplit :: Allocated ( allocated) => {
387
+ Split :: Borrowed ( borrowed) => Self :: borrowed ( & borrowed. as_slice ( ) [ range] ) ,
388
+ Split :: Allocated ( allocated) => {
389
389
// normalize to inline if possible
390
390
if range. len ( ) <= INLINE_CAPACITY {
391
391
// SAFETY: length is checked above
@@ -424,18 +424,18 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
424
424
}
425
425
426
426
let result = match self . split ( ) {
427
- RawSplit :: Inline ( _) => {
427
+ Split :: Inline ( _) => {
428
428
// SAFETY: by the function precondition and the test above
429
429
// slice.len() <= self.len() <= INLINE_CAPACITY
430
430
unsafe { Self :: inline_unchecked ( slice) }
431
431
}
432
- RawSplit :: Borrowed ( _) => {
432
+ Split :: Borrowed ( _) => {
433
433
// SAFETY: by the function precondition and the type invariant
434
434
// slice must have at least the same dynamic lifetime
435
435
let sl: & ' borrow [ u8 ] = unsafe { transmute ( slice) } ;
436
436
Self :: borrowed ( sl)
437
437
}
438
- RawSplit :: Allocated ( allocated) => {
438
+ Split :: Allocated ( allocated) => {
439
439
// normalize to inline if possible
440
440
if slice. len ( ) <= INLINE_CAPACITY {
441
441
// SAFETY: length checked above
@@ -473,9 +473,9 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
473
473
#[ must_use]
474
474
pub fn as_mut_slice ( & mut self ) -> Option < & mut [ u8 ] > {
475
475
match self . split_mut ( ) {
476
- RawSplitMut :: Inline ( inline) => Some ( inline. as_mut_slice ( ) ) ,
477
- RawSplitMut :: Allocated ( allocated) => allocated. as_mut_slice ( ) ,
478
- RawSplitMut :: Borrowed ( _) => None ,
476
+ SplitMut :: Inline ( inline) => Some ( inline. as_mut_slice ( ) ) ,
477
+ SplitMut :: Allocated ( allocated) => allocated. as_mut_slice ( ) ,
478
+ SplitMut :: Borrowed ( _) => None ,
479
479
}
480
480
}
481
481
@@ -487,9 +487,9 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
487
487
#[ inline]
488
488
pub ( super ) unsafe fn as_mut_slice_unchecked ( & mut self ) -> & mut [ u8 ] {
489
489
match self . split_mut ( ) {
490
- RawSplitMut :: Inline ( inline) => inline. as_mut_slice ( ) ,
491
- RawSplitMut :: Allocated ( allocated) => unsafe { allocated. as_mut_slice_unchecked ( ) } ,
492
- RawSplitMut :: Borrowed ( _) => {
490
+ SplitMut :: Inline ( inline) => inline. as_mut_slice ( ) ,
491
+ SplitMut :: Allocated ( allocated) => unsafe { allocated. as_mut_slice_unchecked ( ) } ,
492
+ SplitMut :: Borrowed ( _) => {
493
493
#[ cfg( debug_assertions) ]
494
494
{
495
495
panic ! ( "mutable slice of borrowed string" ) ;
@@ -531,7 +531,7 @@ impl<'borrow, B: Backend> HipByt<'borrow, B> {
531
531
#[ inline]
532
532
pub ( super ) fn take_allocated ( & mut self ) -> Option < Allocated < B > > {
533
533
match self . split ( ) {
534
- RawSplit :: Allocated ( & allocated) => {
534
+ Split :: Allocated ( & allocated) => {
535
535
// Takes a copy of allocated
536
536
537
537
// replace `self` one by an empty raw
@@ -622,9 +622,9 @@ impl<B: Backend> Clone for HipByt<'_, B> {
622
622
fn clone ( & self ) -> Self {
623
623
// Duplicates this `Raw` increasing the ref count if needed.
624
624
match self . split ( ) {
625
- RawSplit :: Inline ( & inline) => Self :: from_inline ( inline) ,
626
- RawSplit :: Borrowed ( & borrowed) => Self :: from_borrowed ( borrowed) ,
627
- RawSplit :: Allocated ( allocated) => {
625
+ Split :: Inline ( & inline) => Self :: from_inline ( inline) ,
626
+ Split :: Borrowed ( & borrowed) => Self :: from_borrowed ( borrowed) ,
627
+ Split :: Allocated ( allocated) => {
628
628
let clone = allocated. explicit_clone ( ) ;
629
629
Self :: from_allocated ( clone)
630
630
}
0 commit comments