Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Debug output doesn't show a difference for foo: and foo:// #693

Closed
glandium opened this issue Mar 27, 2021 · 4 comments
Closed

Debug output doesn't show a difference for foo: and foo:// #693

glandium opened this issue Mar 27, 2021 · 4 comments

Comments

@glandium
Copy link

use url::Url;
fn main() {
  assert_eq!(Url::parse("foo:"), Url::parse("foo://"));
}

shows:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Ok(Url { scheme: "foo", username: "", password: None, host: None, port: None, path: "", query: None, fragment: None })`,
 right: `Ok(Url { scheme: "foo", username: "", password: None, host: None, port: None, path: "", query: None, fragment: None })`', src/main.rs:3:3

(playground link)

There is no visible difference between left and right. Now, imagine the real code being assert_eq!(my_func(), Url::parse(expected).unwrap()); and seeing this error.

@glandium
Copy link
Author

Needless to say, the re-serialization with .as_str() does differ between the two values.

@djc
Copy link
Contributor

djc commented Mar 29, 2021

Yeah, I think I ran into similar problems before. What do you think we should put into the Debug impl instead?

@glandium
Copy link
Author

Maybe exposing cannot_be_a_base would be enough?

@djc
Copy link
Contributor

djc commented Apr 12, 2021

See #699.

valenting added a commit that referenced this issue Apr 13, 2021
Add cannot_be_a_base field to Url's Debug representation (fixes #693)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants