-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Should Path::display
return impl Debug + Display
instead of concrete type?
#80676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Isn't it a breaking change if we change return type by now? |
if we use |
Changing it to rust/library/std/src/sys_common/backtrace.rs Line 230 in a4cbb44
With this error:
The problem is very subtle. For There's no such thing as |
Looks like |
Would it be worth a crater check run, or no? Since this is pretty low-priority, maybe we could consider a crater run on just some popular crates? |
We can't run a crater run if the |
I'm not sure what the motivation for something like this is, even if backcompat weren't a concern. Returning an |
But there's pretty much nothing you can do with |
There are a lot fewer things you can do with an And you absolutely might want to do something with the type. Like maybe wrap it up on another type. |
I guess I would think you could just wrap it like |
That, and now you've introduced a type parameter where one really isn't needed. This dance is kind of supporting my stance. If you return an |
In the case of these display adapters, this wrapper could just contain the |
Why would we make a breaking change to the standard library when "there's not necessarily a reason to do this"? What is the expected outcome of this issue, other than answering the question in the title with "no"? |
Oh we definitely shouldn't change Path::display. That's just a breaking change with no benefit. But the question is relevant to new similar adapters that might be added in the future. E.g. for OsStr, where this question popped up. |
I'm going to close this since we're not going to change Path::display. |
Currently, the
Path::display()
function returns the concretestd::path::Display
type. As far as I can tell, this type's public API consistsof only its implementations of
Debug
andDisplay
. ShouldPath::display()
return a generic
impl Debug + Display
instead of allowing users to rely on itbeing a particular concrete type?
I think the potential breakage is probably none since you can't do anything with
std::path::Display
short of using itsDebug
andDisplay
impls. You couldtheoretically have a function that requires its argument to be of type
std::path::Display
, but I don't see why that would be useful. If there aresuch functions, they could likely be changed to take
impl Debug + Display
.Right now, there's not necessarily a reason to do this, but in general we want
to hide implementation details in case we need to make changes in the future
(cc #80634).
The text was updated successfully, but these errors were encountered: