You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/guessing_game.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
578
-
src/guessing_game.rs:4 println!("The value of x is: {}", x);
579
-
^
580
-
note: in expansion of format_args!
581
-
<std macros>:2:23: 2:77 note: expansion site
582
-
<std macros>:1:1: 3:2 note: in expansion of println!
583
-
src/guessing_game.rs:4:5: 4:42 note: expansion site
584
-
error: aborting due to previous error
585
-
Could not execute process `rustc src/guessing_game.rs --crate-type bin --out-dir /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target/deps` (status=101)
586
-
```
422
+
comments
587
423
588
-
Rust will not let us use a value that has not been initialized. So why let us
589
-
declare a binding without initializing it? You'd think our first example would
590
-
have errored. Well, Rust is smarter than that. Before we get to that, let's talk
591
-
about this stuff we've added to `println!`.
592
-
593
-
If you include two curly braces (`{}`, some call them moustaches...) in your
594
-
string to print, Rust will interpret this as a request to interpolate some sort
595
-
of value. **String interpolation** is a computer science term that means "stick
596
-
in the middle of a string." We add a comma, and then `x`, to indicate that we
597
-
want `x` to be the value we're interpolating. The comma is used to separate
598
-
arguments we pass to functions and macros, if you're passing more than one.
599
-
600
-
When you just use the double curly braces, Rust will attempt to display the
601
-
value in a meaningful way by checking out its type. If you want to specify the
602
-
format in a more detailed manner, there are a [wide number of options
603
-
available](/std/fmt/index.html). Fow now, we'll just stick to the default:
604
-
integers aren't very complicated to print.
605
-
606
-
So, we've cleared up all of the confusion around bindings, with one exception:
607
-
why does Rust let us declare a variable binding without an initial value if we
608
-
must initialize the binding before we use it? And how does it know that we have
609
-
or have not initialized the binding? For that, we need to learn our next
610
-
concept: `if`.
424
+
## Testing
611
425
612
-
## If
426
+
attributes
613
427
614
-
## Functions
428
+
stability markers
615
429
616
-
return
430
+
## Crates and Modules
617
431
618
-
comments
432
+
visibility
619
433
620
434
## Compound Data Types
621
435
@@ -637,35 +451,10 @@ loop
637
451
638
452
break/continue
639
453
640
-
## Guessing Game: complete
641
-
642
-
At this point, you have successfully built the Guessing Game! Congratulations!
0 commit comments