@@ -16,126 +16,243 @@ fn test_arg() {
1616 let t: & str = "hello" ;
1717 assert_eq ! ( "hello" , Arg :: as_str( & t) . unwrap( ) ) ;
1818 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
19- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
20- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
19+ assert_eq ! (
20+ cstr!( "hello" ) ,
21+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
22+ ) ;
23+ assert_eq ! (
24+ cstr!( "hello" ) ,
25+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
26+ ) ;
2127
2228 let t: String = "hello" . to_owned ( ) ;
2329 assert_eq ! ( "hello" , Arg :: as_str( & t) . unwrap( ) ) ;
2430 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
25- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
26- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
31+ assert_eq ! (
32+ cstr!( "hello" ) ,
33+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
34+ ) ;
35+ assert_eq ! (
36+ cstr!( "hello" ) ,
37+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
38+ ) ;
2739
2840 let t: & OsStr = OsStr :: new ( "hello" ) ;
2941 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
3042 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
31- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
32- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
43+ assert_eq ! (
44+ cstr!( "hello" ) ,
45+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
46+ ) ;
47+ assert_eq ! (
48+ cstr!( "hello" ) ,
49+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
50+ ) ;
3351
3452 let t: OsString = OsString :: from ( "hello" . to_owned ( ) ) ;
3553 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
3654 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
37- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
38- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
55+ assert_eq ! (
56+ cstr!( "hello" ) ,
57+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
58+ ) ;
59+ assert_eq ! (
60+ cstr!( "hello" ) ,
61+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
62+ ) ;
3963
4064 let t: & Path = Path :: new ( "hello" ) ;
4165 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
4266 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
43- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
44- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
67+ assert_eq ! (
68+ cstr!( "hello" ) ,
69+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
70+ ) ;
71+ assert_eq ! (
72+ cstr!( "hello" ) ,
73+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
74+ ) ;
4575
4676 let t: PathBuf = PathBuf :: from ( "hello" . to_owned ( ) ) ;
4777 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
4878 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
49- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
50- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
79+ assert_eq ! (
80+ cstr!( "hello" ) ,
81+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
82+ ) ;
83+ assert_eq ! (
84+ cstr!( "hello" ) ,
85+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
86+ ) ;
5187
5288 let t: & CStr = cstr ! ( "hello" ) ;
5389 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
5490 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
55- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
56- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
91+ assert_eq ! (
92+ cstr!( "hello" ) ,
93+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
94+ ) ;
95+ assert_eq ! (
96+ cstr!( "hello" ) ,
97+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
98+ ) ;
5799
58100 let t: CString = cstr ! ( "hello" ) . to_owned ( ) ;
59101 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
60102 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
61103 assert_eq ! (
62104 cstr!( "hello" ) ,
63- Borrow :: borrow( & Arg :: as_cow_c_str( & t) . unwrap( ) )
105+ Borrow :: <CStr >:: borrow( & Arg :: as_cow_c_str( & t) . unwrap( ) )
106+ ) ;
107+ assert_eq ! (
108+ cstr!( "hello" ) ,
109+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
64110 ) ;
65- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
66111
67112 let t: Components < ' _ > = Path :: new ( "hello" ) . components ( ) ;
68113 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
69114 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
70- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
71- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
115+ assert_eq ! (
116+ cstr!( "hello" ) ,
117+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
118+ ) ;
119+ assert_eq ! (
120+ cstr!( "hello" ) ,
121+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
122+ ) ;
72123
73124 let t: Component < ' _ > = Path :: new ( "hello" ) . components ( ) . next ( ) . unwrap ( ) ;
74125 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
75126 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
76- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
77- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
127+ assert_eq ! (
128+ cstr!( "hello" ) ,
129+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
130+ ) ;
131+ assert_eq ! (
132+ cstr!( "hello" ) ,
133+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
134+ ) ;
78135
79136 let t: Iter < ' _ > = Path :: new ( "hello" ) . iter ( ) ;
80137 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
81138 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
82- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
83- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
139+ assert_eq ! (
140+ cstr!( "hello" ) ,
141+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
142+ ) ;
143+ assert_eq ! (
144+ cstr!( "hello" ) ,
145+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
146+ ) ;
84147
85148 let t: Cow < ' _ , str > = Cow :: Borrowed ( "hello" ) ;
86149 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
87150 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
88- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
89- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
151+ assert_eq ! (
152+ cstr!( "hello" ) ,
153+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
154+ ) ;
155+ assert_eq ! (
156+ cstr!( "hello" ) ,
157+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
158+ ) ;
90159
91160 let t: Cow < ' _ , str > = Cow :: Owned ( "hello" . to_owned ( ) ) ;
92161 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
93162 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
94- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
95- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
163+ assert_eq ! (
164+ cstr!( "hello" ) ,
165+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
166+ ) ;
167+ assert_eq ! (
168+ cstr!( "hello" ) ,
169+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
170+ ) ;
96171
97172 let t: Cow < ' _ , OsStr > = Cow :: Borrowed ( OsStr :: new ( "hello" ) ) ;
98173 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
99174 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
100- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
101- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
175+ assert_eq ! (
176+ cstr!( "hello" ) ,
177+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
178+ ) ;
179+ assert_eq ! (
180+ cstr!( "hello" ) ,
181+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
182+ ) ;
102183
103184 let t: Cow < ' _ , OsStr > = Cow :: Owned ( OsString :: from ( "hello" . to_owned ( ) ) ) ;
104185 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
105186 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
106- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
107- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
187+ assert_eq ! (
188+ cstr!( "hello" ) ,
189+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
190+ ) ;
191+ assert_eq ! (
192+ cstr!( "hello" ) ,
193+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
194+ ) ;
108195
109196 let t: Cow < ' _ , CStr > = Cow :: Borrowed ( cstr ! ( "hello" ) ) ;
110197 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
111198 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
112- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
113- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
199+ assert_eq ! (
200+ cstr!( "hello" ) ,
201+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
202+ ) ;
203+ assert_eq ! (
204+ cstr!( "hello" ) ,
205+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
206+ ) ;
114207
115208 let t: Cow < ' _ , CStr > = Cow :: Owned ( cstr ! ( "hello" ) . to_owned ( ) ) ;
116209 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
117210 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
118- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
119- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
211+ assert_eq ! (
212+ cstr!( "hello" ) ,
213+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
214+ ) ;
215+ assert_eq ! (
216+ cstr!( "hello" ) ,
217+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
218+ ) ;
120219
121220 let t: & [ u8 ] = b"hello" ;
122221 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
123222 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
124- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
125- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
223+ assert_eq ! (
224+ cstr!( "hello" ) ,
225+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
226+ ) ;
227+ assert_eq ! (
228+ cstr!( "hello" ) ,
229+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
230+ ) ;
126231
127232 let t: Vec < u8 > = b"hello" . to_vec ( ) ;
128233 assert_eq ! ( "hello" , t. as_str( ) . unwrap( ) ) ;
129234 assert_eq ! ( "hello" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
130- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
131- assert_eq ! ( cstr!( "hello" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
235+ assert_eq ! (
236+ cstr!( "hello" ) ,
237+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
238+ ) ;
239+ assert_eq ! (
240+ cstr!( "hello" ) ,
241+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
242+ ) ;
132243
133244 let t: DecInt = DecInt :: new ( 43110 ) ;
134245 assert_eq ! ( "43110" , t. as_str( ) ) ;
135246 assert_eq ! ( "43110" . to_owned( ) , Arg :: to_string_lossy( & t) ) ;
136- assert_eq ! ( cstr!( "43110" ) , Borrow :: borrow( & t. as_cow_c_str( ) . unwrap( ) ) ) ;
247+ assert_eq ! (
248+ cstr!( "43110" ) ,
249+ Borrow :: <CStr >:: borrow( & t. as_cow_c_str( ) . unwrap( ) )
250+ ) ;
137251 assert_eq ! ( cstr!( "43110" ) , t. as_c_str( ) ) ;
138- assert_eq ! ( cstr!( "43110" ) , Borrow :: borrow( & t. into_c_str( ) . unwrap( ) ) ) ;
252+ assert_eq ! (
253+ cstr!( "43110" ) ,
254+ Borrow :: <CStr >:: borrow( & t. into_c_str( ) . unwrap( ) )
255+ ) ;
139256}
140257
141258#[ test]
0 commit comments