Skip to content

Url's Debug trait should NOT show parsed components #1015

Open
@raimundomartins

Description

@raimundomartins

The behavior before #596 was best for anyone not working very closely with the Urls. Showing parsed components just makes things unreadable, it's the difference between

{
"default": Some({Web: "https://video.com/web/feature.mp4", Android: "https://video.com/android/feature.mp4"}),
NOR: {Web: "https://video.no/web/feature.mp4", Android: "https://video.no/android/feature.mp4"}
}

and

{
default: Some({Web: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("video.com")), port: None, path: "/web/feature.mp4", query: None, fragment: None }, Android: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("video.com")), port: None, path: "/android/feature.mp4", query: None, fragment: None }}),
NOR: {Web: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("video.no")), port: None, path: "/web/feature.mp4", query: None, fragment: None }, Android: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("video.no")), port: None, path: "/android/feature.mp4", query: None, fragment: None }}
}

They are the same struct, but the first one has a custom implementation of Debug. In a bigger struct with several of these, it makes a whole lot of difference. Since I have several structs that use Url, I used derive_more::Debug but in some cases helper structs are needed because of lifetimes.

This is a lot of unnecessary trouble, I just want to ensure that the Urls are valid before I pass them along, I don't even use them. What are your thoughts on a feature that debugs Url as it is displayed, would such a PR be accepted?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions