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

guide: Remove reference to uninitialized bindings #17107

Merged
merged 1 commit into from
Sep 9, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,8 @@ error: aborting due to previous error
Could not compile `hello_world`.
```

Rust will not let us use a value that has not been initialized. So why let us
declare a binding without initializing it? You'd think our first example would
have errored. Well, Rust is smarter than that. Before we get to that, let's talk
about this stuff we've added to `println!`.
Rust will not let us use a value that has not been initialized. Next, let's
talk about this stuff we've added to `println!`.

If you include two curly braces (`{}`, some call them moustaches...) in your
string to print, Rust will interpret this as a request to interpolate some sort
Expand All @@ -538,12 +536,6 @@ format in a more detailed manner, there are a [wide number of options
available](std/fmt/index.html). For now, we'll just stick to the default:
integers aren't very complicated to print.

So, we've cleared up all of the confusion around bindings, with one exception:
why does Rust let us declare a variable binding without an initial value if we
must initialize the binding before we use it? And how does it know that we have
or have not initialized the binding? For that, we need to learn our next
concept: `if`.

# If

Rust's take on `if` is not particularly complex, but it's much more like the
Expand Down Expand Up @@ -582,7 +574,6 @@ if x == 5i {

This is all pretty standard. However, you can also do this:


```
let x = 5i;

Expand Down