File tree Expand file tree Collapse file tree 2 files changed +31
-20
lines changed Expand file tree Collapse file tree 2 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -34,23 +34,3 @@ impl TextSized for char {
34
34
( self . len_utf8 ( ) as u32 ) . into ( )
35
35
}
36
36
}
37
-
38
- // assertion shape from static_assertions::assert_impl_all!
39
- const _: fn ( ) = || {
40
- use std:: borrow:: Cow ;
41
-
42
- fn assert_impl < T : TextSized > ( ) { }
43
-
44
- assert_impl :: < & String > ( ) ;
45
- assert_impl :: < & Cow < str > > ( ) ;
46
-
47
- struct StringLike { }
48
- impl Deref for StringLike {
49
- type Target = str ;
50
- fn deref ( & self ) -> & str {
51
- unreachable ! ( )
52
- }
53
- }
54
-
55
- assert_impl :: < & StringLike > ( ) ;
56
- } ;
Original file line number Diff line number Diff line change
1
+ use {
2
+ std:: { borrow:: Cow , ops:: Deref } ,
3
+ text_size:: * ,
4
+ } ;
5
+
6
+ struct StringLike < ' a > ( & ' a str ) ;
7
+
8
+ impl Deref for StringLike < ' _ > {
9
+ type Target = str ;
10
+ fn deref ( & self ) -> & Self :: Target {
11
+ & self . 0
12
+ }
13
+ }
14
+
15
+ #[ test]
16
+ fn main ( ) {
17
+ let s = "" ;
18
+ let _ = TextSize :: of ( & s) ;
19
+
20
+ let s = String :: new ( ) ;
21
+ let _ = TextSize :: of ( & s) ;
22
+
23
+ let s = Cow :: Borrowed ( "" ) ;
24
+ let _ = TextSize :: of ( & s) ;
25
+
26
+ let s = Cow :: Owned ( String :: new ( ) ) ;
27
+ let _ = TextSize :: of ( & s) ;
28
+
29
+ let s = StringLike ( "" ) ;
30
+ let _ = TextSize :: of ( & s) ;
31
+ }
You can’t perform that action at this time.
0 commit comments