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

Collect literal examples together in the reference #18441

Merged
merged 2 commits into from
Nov 21, 2014

Conversation

mdinger
Copy link
Contributor

@mdinger mdinger commented Oct 29, 2014

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.

@mdinger
Copy link
Contributor Author

mdinger commented Oct 30, 2014

Repushed. Updated to an absolute reference in std::str because a relative didn't work.

| [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` |
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a server to upload it to...here's a screenshot though:
literals

Screenshot2:
numbers

@steveklabnik
Copy link
Member

this is a pretty good idea, thanks! 👍

@mdinger
Copy link
Contributor Author

mdinger commented Oct 30, 2014

Repushed to align "Example character and strings" header.

|---------------|------|
| `\x7F` | 8-bit character code |
| `\u7FFF` | 16-bit character code |
| `\U7EEEFFFF` | 32-bit character code |
Copy link
Contributor Author

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.

@mdinger
Copy link
Contributor Author

mdinger commented Nov 1, 2014

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.

Rendered
Added updated below

@mdinger
Copy link
Contributor Author

mdinger commented Nov 4, 2014

r? @steveklabnik

@mdinger
Copy link
Contributor Author

mdinger commented Nov 15, 2014

Is this good to merge? Is there interest in this? Any changes needed?

@alexcrichton
Copy link
Member

Assigning to @steveklabnik so we can keep better track of this, sorry for the delay @mdinger!

@mdinger
Copy link
Contributor Author

mdinger commented Nov 15, 2014

Sounds good

@bstrie
Copy link
Contributor

bstrie commented Nov 20, 2014

Looks like this needs a rebase.

@mdinger
Copy link
Contributor Author

mdinger commented Nov 20, 2014

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.


Render 1:
literals1


Render 2:
literals2


r?

@steveklabnik
Copy link
Member

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) |
Copy link
Contributor Author

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.

@mdinger
Copy link
Contributor Author

mdinger commented Nov 20, 2014

Thanks

bors added a commit that referenced this pull request Nov 21, 2014
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.
@bors bors closed this Nov 21, 2014
@bors bors merged commit 16bb4e6 into rust-lang:master Nov 21, 2014
@mdinger mdinger deleted the literals branch January 2, 2015 20:52
lnicola pushed a commit to lnicola/rust that referenced this pull request Dec 11, 2024
internal: Do not cache the config directory path
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

Successfully merging this pull request may close these issues.

str escape sequences are undocumented
5 participants