@@ -86,7 +86,7 @@ impl UDateFormat {
86
86
"programmer error: date_style may not be UDAT_PATTERN"
87
87
) ;
88
88
// pattern is ignored if time_style or date_style aren't equal to pattern.
89
- let pattern = ustring:: UChar :: try_from ( "" ) . expect ( "pattern created ") ;
89
+ let pattern = ustring:: UChar :: from ( " ") ;
90
90
91
91
Self :: new_internal ( time_style, date_style, loc, tz_id, & pattern)
92
92
}
@@ -158,7 +158,7 @@ impl UDateFormat {
158
158
///
159
159
/// Implements `udat_parse`
160
160
pub fn parse ( & self , datetime : & str ) -> Result < sys:: UDate , common:: Error > {
161
- let datetime_uc = ustring:: UChar :: try_from ( datetime) ? ;
161
+ let datetime_uc = ustring:: UChar :: from ( datetime) ;
162
162
self . parse_from_position ( & datetime_uc, 0 ) . map ( |r| r. date )
163
163
}
164
164
@@ -243,7 +243,7 @@ impl UDateFormat {
243
243
} ;
244
244
common:: Error :: ok_or_warning ( status) ?;
245
245
}
246
- String :: try_from ( & result)
246
+ String :: try_from ( & result) . map_err ( |e| e . into ( ) )
247
247
}
248
248
}
249
249
@@ -340,7 +340,7 @@ mod tests {
340
340
] ;
341
341
for t in tests {
342
342
let loc = uloc:: ULoc :: try_from ( t. locale ) ?;
343
- let tz_id = ustring:: UChar :: try_from ( t. timezone ) ? ;
343
+ let tz_id = ustring:: UChar :: from ( t. timezone ) ;
344
344
345
345
let mut fmt = UDateFormat :: new_with_styles (
346
346
sys:: UDateFormatStyle :: UDAT_FULL ,
@@ -385,9 +385,9 @@ mod tests {
385
385
} ,
386
386
] ;
387
387
let loc = uloc:: ULoc :: try_from ( "en-US" ) ?;
388
- let tz_id = ustring:: UChar :: try_from ( "America/New_York" ) ? ;
388
+ let tz_id = ustring:: UChar :: from ( "America/New_York" ) ;
389
389
for t in tests {
390
- let pattern = ustring:: UChar :: try_from ( t. pattern ) ? ;
390
+ let pattern = ustring:: UChar :: from ( t. pattern ) ;
391
391
let fmt = UDateFormat :: new_with_pattern ( & loc, & tz_id, & pattern) ?;
392
392
let actual = fmt. format ( t. date ) ?;
393
393
assert_eq ! (
@@ -422,10 +422,10 @@ mod tests {
422
422
] ;
423
423
424
424
let loc = uloc:: ULoc :: try_from ( "en-US" ) ?;
425
- let tz_id = ustring:: UChar :: try_from ( "America/New_York" ) ? ;
425
+ let tz_id = ustring:: UChar :: from ( "America/New_York" ) ;
426
426
427
427
for test in tests {
428
- let pattern = ustring:: UChar :: try_from ( test. pattern ) ? ;
428
+ let pattern = ustring:: UChar :: from ( test. pattern ) ;
429
429
let format = UDateFormat :: new_with_pattern ( & loc, & tz_id, & pattern) ?;
430
430
let actual = format. parse ( test. input ) ?;
431
431
assert_eq ! (
0 commit comments