Conversation
|
PRELIMINARY PR: Do not merge until the RFC is approved. |
|
Per IRC: @alexcrichton is very uncomfortable with these living in |
|
cc @reem |
|
Per IRC: @reem points out that the same coherence problems make it much more difficult to define "implicit conversions" via generics targetting user-land types: you cannot implement Introducing an ad hoc conversion trait, on the other hand, makes it possible to do this in userland. |
|
Updated: I've now moved the traits into |
c8671be to
3c62067
Compare
|
☔ The latest upstream changes (presumably #23548) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I believe this is now ready to go, once the RFC itself has been merged. |
src/libcollections/borrow.rs
Outdated
There was a problem hiding this comment.
Could these traits also go into the libcore prelude? I think files like this can have use core::prelude::* at the top as well (slowly been migrating over time).
|
cc #23567 |
|
Updated:
All in all, I feel much better with the form this PR is taking now. It feels cleaner, leaner, more consistent and more extensible. Thanks for the feedback making this possible! @alexcrichton: re-r? |
src/libstd/env.rs
Outdated
There was a problem hiding this comment.
Could this module import Path directly and use AsRef<Path>?
There was a problem hiding this comment.
Ahha! It can now. I think when I first wrote it Path was still in the prelude :)
|
I, too, am quite happy with how this is turning out! r=me with the |
|
pings addressed :) |
|
@bors: r=alexcrichton 97c8e43 |
Conflicts: src/librustc_back/rpath.rs
This commit: * Introduces `std::convert`, providing an implementation of RFC 529. * Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all in favor of the corresponding generic conversion traits. Consequently, various IO APIs now take `AsRef<Path>` rather than `AsPath`, and so on. Since the types provided by `std` implement both traits, this should cause relatively little breakage. * Deprecates many `from_foo` constructors in favor of `from`. * Changes `PathBuf::new` to take no argument (creating an empty buffer, as per convention). The previous behavior is now available as `PathBuf::from`. * De-stabilizes `IntoCow`. It's not clear whether we need this separate trait. Closes rust-lang#22751 Closes rust-lang#14433 [breaking-change]
|
Rolled into #23654 |
|
☔ The latest upstream changes (presumably #23654) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit:
Introduces
std::convert, providing an implementation ofRFC 529.
Deprecates the
AsPath,AsOsStr, andIntoBytestraits, allin favor of the corresponding generic conversion traits.
Consequently, various IO APIs now take
As<Path>rather thanAsPath, and so on. Since the types provided bystdimplement bothtraits, this should cause relatively little breakage.
Deprecates many
from_fooconstructors in favor offrom.Changes
PathBuf::newto take no argument (creating an empty buffer,as per convention). The previous behavior is now available as
PathBuf::from.De-stabilizes
IntoCow. It's not clear whether we need this separate trait.Closes #14433
Closes #22751
[breaking-change]
r? @alexcrichton
cc @gankro @erickt @cmr