11// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
22// SPDX-License-Identifier: Apache-2.0
33
4+ use alloc:: borrow:: Cow ;
5+ use core:: ffi:: c_char;
6+ use core:: fmt:: { Debug , Display , Formatter } ;
7+ use core:: hash:: { Hash , Hasher } ;
8+ use core:: marker:: PhantomData ;
49use core:: slice;
10+ use core:: str:: Utf8Error ;
511use libdd_common:: error:: FfiSafeErrorMessage ;
612use serde:: ser:: Error ;
713use serde:: Serializer ;
8- use std:: borrow:: Cow ;
9- use std:: fmt:: { Debug , Display , Formatter } ;
10- use std:: hash:: { Hash , Hasher } ;
11- use std:: marker:: PhantomData ;
12- use std:: os:: raw:: c_char;
13- use std:: str:: Utf8Error ;
1414
1515#[ repr( C ) ]
1616#[ derive( Clone , Copy , Debug ) ]
@@ -37,7 +37,7 @@ pub struct Slice<'a, T: 'a> {
3737/// # Safety
3838/// All strings are valid UTF-8 (enforced by using c-str literals in Rust).
3939unsafe impl FfiSafeErrorMessage for SliceConversionError {
40- fn as_ffi_str ( & self ) -> & ' static std :: ffi:: CStr {
40+ fn as_ffi_str ( & self ) -> & ' static core :: ffi:: CStr {
4141 match self {
4242 SliceConversionError :: LargeLength => c"length was too large" ,
4343 SliceConversionError :: NullPointer => c"null pointer with non-zero length" ,
@@ -46,7 +46,7 @@ unsafe impl FfiSafeErrorMessage for SliceConversionError {
4646 }
4747}
4848impl Display for SliceConversionError {
49- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std :: fmt:: Result {
49+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core :: fmt:: Result {
5050 Display :: fmt ( self . as_rust_str ( ) , f)
5151 }
5252}
@@ -62,7 +62,7 @@ impl<'a, T: 'a> core::ops::Deref for Slice<'a, T> {
6262}
6363
6464impl < T : Debug > Debug for Slice < ' _ , T > {
65- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std :: fmt:: Result {
65+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core :: fmt:: Result {
6666 self . as_slice ( ) . fmt ( f)
6767 }
6868}
@@ -106,7 +106,7 @@ pub trait AsBytes<'a> {
106106
107107 #[ inline]
108108 fn try_to_utf8 ( & self ) -> Result < & ' a str , Utf8Error > {
109- std :: str:: from_utf8 ( self . as_bytes ( ) )
109+ core :: str:: from_utf8 ( self . as_bytes ( ) )
110110 }
111111
112112 fn try_to_string ( & self ) -> Result < String , Utf8Error > {
@@ -127,7 +127,7 @@ pub trait AsBytes<'a> {
127127 /// # Safety
128128 /// Must only be used when the underlying data was already confirmed to be utf8.
129129 unsafe fn assume_utf8 ( & self ) -> & ' a str {
130- std :: str:: from_utf8_unchecked ( self . as_bytes ( ) )
130+ core :: str:: from_utf8_unchecked ( self . as_bytes ( ) )
131131 }
132132}
133133
@@ -276,8 +276,8 @@ impl<'a, T> Display for Slice<'a, T>
276276where
277277 Slice < ' a , T > : AsBytes < ' a > ,
278278{
279- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std :: fmt:: Result {
280- write ! ( f, "{}" , self . try_to_utf8( ) . map_err( |_| std :: fmt:: Error ) ?)
279+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> core :: fmt:: Result {
280+ write ! ( f, "{}" , self . try_to_utf8( ) . map_err( |_| core :: fmt:: Error ) ?)
281281 }
282282}
283283
@@ -322,8 +322,8 @@ impl<'a> CharSlice<'a> {
322322#[ cfg( test) ]
323323mod tests {
324324 use super :: * ;
325+ use core:: ptr;
325326 use std:: os:: raw:: c_char;
326- use std:: ptr;
327327
328328 #[ test]
329329 fn slice_from_into_slice ( ) {
0 commit comments