-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Collect literal examples together in the reference #18441
Conversation
Repushed. Updated to an absolute reference in |
| [Raw](#Raw-string-literals) | `r##"hello"##` | `0...` | `N/A` | | ||
| [Byte](#Byte-literals) | `b'H'` | `N/A` | `\'` & Extra escapes | | ||
| [Byte string](#Byte-string-literals) | `b"hello"` | `N/A` | `\"` & Extra escapes | | ||
| [Raw byte string](#Raw-byte-string-literals) | `br##"hello"##` | `0...` | `N/A` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these tables render correctly even though the pipes aren't lined up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I followed the the Github markdown example which shows the first pipe aligned. The rest are automatic. Like so:
First Header | Second Header
------------ | -------------
Content from cell 1 | Content from cell 2
Content in the first column | Content in the second column
Generates:
First Header | Second Header |
---|---|
Content from cell 1 | Content from cell 2 |
Content in the first column | Content in the second column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a pretty good idea, thanks! 👍 |
Repushed to align "Example character and strings" header. |
|---------------|------| | ||
| `\x7F` | 8-bit character code | | ||
| `\u7FFF` | 16-bit character code | | ||
| `\U7EEEFFFF` | 32-bit character code | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Byte literals don't support 16-bit
and 32-bit
escapes which I need to fix.
Repushed to fix Byte escapes and added a column for Available characters. I tried to keep the lines short but it messed up the tables and I couldn't find how to escape a newline in markdown.
|
Is this good to merge? Is there interest in this? Any changes needed? |
Assigning to @steveklabnik so we can keep better track of this, sorry for the delay @mdinger! |
Sounds good |
Looks like this needs a rebase. |
Rebased. I know the source table lines are really long but when I originally tried to shorten them, it ruined the rendered table formatting. Added an "Equivalent to" column which I'm uncertain if is necessary but it might be good. Table is big and oddly formatted but seems quite useful. r? |
Looks good to me! |
| [Raw](#raw-string-literals) | `r##"hello"##` | `0...` | All unicode | `N/A` | `N/A` | | ||
| [Byte](#byte-literals) | `b'H'` | `N/A` | All ASCII | `\'` & [Byte escapes](#byte-escapes) | `u8` | | ||
| [Byte string](#byte-string-literals) | `b"hello"` | `N/A` | All ASCII | `\"` & [Byte escapes](#byte-escapes) | `&'static [u8]` | | ||
| [Raw byte string](#raw-byte-string-literals) | `br##"hello"##` | `0...` | All ASCII | `N/A` | `&'static [u8]` (unsure...not stated) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this last column, if it needs updating. Other than that though, it's good.
Thanks |
Closes #18415 This links [`std::str`](http://doc.rust-lang.org/std/str/index.html) documentation to [literals](http://doc.rust-lang.org/reference.html#literals) in the reference guide and collects examples of literals into one group at the beginning of the section. ~~The new tables are not exhaustive (some escapes were skipped) and so I try to link back to the respective sections where more detail is located.~~ The tables are are mostly exhaustive. I misunderstood some of the whitespace codes. I don't think the tables actually look that nice if that's important and I'm not sure how it could be improved. I think it does do a good job of collecting available options together. I think listing the escapes together is particularly helpful because they vary with type and are embedded in paragraphs. [EDIT] The [ascii table](http://man-ascii.com/) is here and may be useful.
internal: Do not cache the config directory path
Closes #18415
This links
std::str
documentation to literals in the reference guide and collects examples of literals into one group at the beginning of the section.The new tables are not exhaustive (some escapes were skipped) and so I try to link back to the respective sections where more detail is located.The tables are are mostly exhaustive. I misunderstood some of the whitespace codes.I don't think the tables actually look that nice if that's important and I'm not sure how it could be improved. I think it does do a good job of collecting available options together. I think listing the escapes together is particularly helpful because they vary with type and are embedded in paragraphs.
[EDIT]
The ascii table is here and may be useful.