Skip to content

Commit

Permalink
Different line wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid authored and Noratrieb committed Jun 4, 2024
1 parent 6151848 commit 3757b61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/misc/8.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,16 @@ There are 3 kinds of structs in Rust:

All 3 kinds can have a struct with no fields.

Types and values live in separate namespaces, as it is usually [^not1] possible to
syntactically determine whether an identifier the compiler needs to resolve will
be an value or type .
Types and values live in separate namespaces, as it is usually [^not1] possible to syntactically determine whether an identifier the compiler needs to resolve will be an value or type .

[^not1]: except when it isn't :)

This means that `struct bar {}` only gets inserted into the type namespace, and `fn
bar` only gets inserted to the value namespace (as functions in Rust are first
class values [^not]). Therefore both of these declarations can co-exist.
This means that `struct bar {}` only gets inserted into the type namespace, and `fn bar` only gets inserted to the value namespace (as functions in Rust are first
class values [^not]).
Therefore both of these declarations can co-exist.

However for `struct foo`, because it's a tuple struct, it also needs to insert
the constructor into the value namespace. (This isn't quite the same as
inserting a function, as it's also valid in pattern matching, but it's close).
This then clashes with `fn foo`, which also lives in the value namespace,
causing the compiler error.
However for `struct foo`, because it's a tuple struct, it also needs to insert the constructor into the value namespace. (This isn't quite the same as inserting a function, as it's also valid in pattern matching, but it's close).
This then clashes with `fn foo`, which also lives in the value namespace, causing the compiler error.

[^not] except when they're not :)

Expand Down
3 changes: 1 addition & 2 deletions src/misc/9.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
{{#include ../../code/examples/stderr/misc_9.stderr}}
```

No matter what kind a struct is, it can always be initialized with braces (even
if not declared with them). Therefor the first 3 statements are OK.
No matter what kind a struct is, it can always be initialized with braces (even if not declared with them). Therefor the first 3 statements are OK.

`A;` on it's own is fine, because `A` is declared as a unit struct, so `A` is a constant of type `A`.

Expand Down

0 comments on commit 3757b61

Please sign in to comment.