Skip to content
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

Debug (Hello World/Formatted print/) output has a backwards slash in it #571

Closed
KingOfThePirates opened this issue May 9, 2015 · 3 comments

Comments

@KingOfThePirates
Copy link

http://rustbyexample.com/hello/print/print_debug.html

println!("{1:?} {0:?} is the {actor:?} name.",
             "Slater",
             "Christian",
             actor="actor's");

Output
"Christian" "Slater" is the "actor\'s" name.

@mdinger
Copy link
Contributor

mdinger commented May 9, 2015

Why is this a problem? This example is examining fmt::Debug and that's what his looks like when Debug is applied.

@KingOfThePirates
Copy link
Author

I understand where the backwards slash might come from because of my Java background, but nowhere in the Rust book or Rust by Example does it even mention escape sequences, much less tell you what kinds of them there are, and, regardless, the example does not even use one- it just pops up in the output.

I do not want to program by coincidence- what the hell is going on here?

Why is this ok?

@mdinger
Copy link
Contributor

mdinger commented May 11, 2015

It's probably just this bug: rust-lang/rust#24588. A comparison with fmt::Display on playpen: http://is.gd/NZS0GZ

From an instruction standpoint I don't consider it that big an issue though. fmt::Debug doesn't always format things in an ideal way. \' obviously isn't ideal and if that's a problem, use fmt::Display. Either way, it's just how Rust prints for now. It's a bigger issue with those unicode characters in the playpen link; you can't even tell what they are supposed to be without a look-up table.

If it bothers you though, submit a PR to add a comment about it. It's just that the fmt::Debug implementation isn't being smart enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants