Skip to content

Commit

Permalink
Rollup merge of rust-lang#30727 - tbu-:pr_doc_escaped_newline, r=stev…
Browse files Browse the repository at this point in the history
…eklabnik

Rust differs in that behavior from C: In C, the newline escapes are resolved
before anything else, and in Rust this depends on whether the backslash is
escaped itself.

A difference can be observed in the following two programs:

```c
int main()
{
	printf("\\
n\n");
	return 0;
}
```

```rust
fn main() {
	println!("\\
n");
}
```

The first program prints two newlines, the second one prints a backslash, a
newline, the latin character n and a final newline.
  • Loading branch information
steveklabnik committed Jan 6, 2016
2 parents eb41060 + ce6baa7 commit fcb1ccf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
which must be _escaped_ by a preceding `U+005C` character (`\`).

Line-break characters are allowed in string literals. Normally they represent
themselves (i.e. no translation), but as a special exception, when a `U+005C`
character (`\`) occurs immediately before the newline, the `U+005C` character,
the newline, and all whitespace at the beginning of the next line are ignored.
Thus `a` and `b` are equal:
themselves (i.e. no translation), but as a special exception, when an unescaped
`U+005C` character (`\`) occurs immediately before the newline (`U+000A`), the
`U+005C` character, the newline, and all whitespace at the beginning of the
next line are ignored. Thus `a` and `b` are equal:

```rust
let a = "foobar";
Expand Down

0 comments on commit fcb1ccf

Please sign in to comment.