Commit 3a3227c
committed
Implement
Being able to generically convert strings can be beneficial for argument
parsing code and similar situations especially in case of conditional
conversions. The standard library already provided this converion, just
not via a trait. This commit fills the gap by adding the impl.
This addition was approved in [ACP 732]. It was requested that
`FromUtf8Error` should be made generic over the input and this commit
obeys the request. However some challenges were encountered:
* The fields were private and the type had no constructor - solved by
making the fields public but unstable and `#[doc(hidden)]`.
* There is a method to perform lossy conversion and it looks like it
should be provided for `OsString` as well - this is not yet resolved.
* `into_os_string` method was requested but the types are in different
crates - solved with `#[rustc_allow_incoherent_impl]`.
[ACP 732]: rust-lang/libs-team#732TryFrom<OsString> for String
1 parent e96bb7e commit 3a3227c
3 files changed
Lines changed: 55 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
389 | 390 | | |
390 | 391 | | |
391 | | - | |
392 | | - | |
393 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
394 | 399 | | |
395 | 400 | | |
396 | 401 | | |
| |||
560 | 565 | | |
561 | 566 | | |
562 | 567 | | |
563 | | - | |
| 568 | + | |
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
| |||
2224 | 2229 | | |
2225 | 2230 | | |
2226 | 2231 | | |
2227 | | - | |
| 2232 | + | |
2228 | 2233 | | |
2229 | 2234 | | |
2230 | 2235 | | |
| |||
2251 | 2256 | | |
2252 | 2257 | | |
2253 | 2258 | | |
2254 | | - | |
| 2259 | + | |
2255 | 2260 | | |
2256 | 2261 | | |
2257 | 2262 | | |
2258 | | - | |
| 2263 | + | |
2259 | 2264 | | |
2260 | 2265 | | |
2261 | 2266 | | |
2262 | 2267 | | |
2263 | 2268 | | |
2264 | 2269 | | |
2265 | 2270 | | |
2266 | | - | |
| 2271 | + | |
2267 | 2272 | | |
2268 | 2273 | | |
2269 | 2274 | | |
| |||
2294 | 2299 | | |
2295 | 2300 | | |
2296 | 2301 | | |
2297 | | - | |
| 2302 | + | |
2298 | 2303 | | |
| 2304 | + | |
2299 | 2305 | | |
| 2306 | + | |
2300 | 2307 | | |
2301 | 2308 | | |
2302 | 2309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
619 | 657 | | |
620 | 658 | | |
621 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| |||
0 commit comments