Extra character in rust book

https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html rustbook-en/src/ch04-01-what-is-ownership.md

Extra symbol is {

This is probably intentional. After all, β€œfn main() {” is the first line of every main-function.

For further things you notice while reading the book, please consider alternative channels, this forum is probably not the optimal place.

2 Likes

where } ?

2 Likes

this is untrue, main is allowed to return any type that implements Termination

1 Like

Alright… let me amend my statement:

β€œfn main() {” is the first line of every main-function that the book had contained so far. And thus the first line of every main-function that the book expects you to come up with yourself from that point – at least up to chapter 9 – in order to run the code examples.

5 Likes

Not part of the quotation.

When you have a passage of natural-language text that quotes some computer code, the author of the natural-language text may choose to quote only a fragment of the code -- not enough to be a complete program, or even a complete expression. And that's perfectly fine. In fact, it is often the best way to write something that achieves the goal of the natural-language text, whatever that is.

In the passage you quoted in your original post, I think the point of writing

we won't include all the fn main() { code in examples

instead of

we won't include all the fn main() code in examples

was to emphasize that the {, and the matching but unquoted }, are part of the "boilerplate" that is being omitted from examples below this point, that "you" will have to add manually if you are following along. I might or might not have chosen to do the same, but I don't see anything wrong with it.

1 Like