File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -256,10 +256,23 @@ impl PartialEq<ColdString> for &str {
256256 }
257257}
258258
259+ impl AsRef < str > for ColdString {
260+ #[ inline]
261+ fn as_ref ( & self ) -> & str {
262+ self . as_str ( )
263+ }
264+ }
265+
266+ impl AsRef < [ u8 ] > for ColdString {
267+ #[ inline]
268+ fn as_ref ( & self ) -> & [ u8 ] {
269+ self . as_bytes ( )
270+ }
271+ }
272+
259273#[ cfg( test) ]
260274mod tests {
261275 use super :: * ;
262- use core:: hash:: BuildHasher ;
263276
264277 #[ test]
265278 fn test_layout ( ) {
@@ -282,8 +295,11 @@ mod tests {
282295 assert_eq ! ( cs. len( ) , s. len( ) ) ;
283296 assert_eq ! ( cs. len( ) < 8 , cs. is_inline( ) ) ;
284297 assert_eq ! ( cs. clone( ) , cs) ;
285- let bh = core:: hash:: RandomState :: new ( ) ;
286- assert_eq ! ( bh. hash_one( & cs) , bh. hash_one( & cs. clone( ) ) ) ;
298+ if cfg ! ( feature = "std" ) {
299+ use core:: hash:: BuildHasher ;
300+ let bh = std:: hash:: RandomState :: new ( ) ;
301+ assert_eq ! ( bh. hash_one( & cs) , bh. hash_one( & cs. clone( ) ) ) ;
302+ }
287303 assert_eq ! ( cs, s) ;
288304 assert_eq ! ( s, cs) ;
289305 assert_eq ! ( cs, * s) ;
You can’t perform that action at this time.
0 commit comments