Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
a2_guessing_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D7018E-SS-RUST
a2_guessing_game
Commits
a27bc1bf
Commit
a27bc1bf
authored
7 years ago
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Ran cargo fmt
parent
16b76d6e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+11
-13
11 additions, 13 deletions
src/main.rs
with
11 additions
and
13 deletions
src/main.rs
+
11
−
13
View file @
a27bc1bf
...
...
@@ -16,7 +16,6 @@ fn main() {
println!
(
"The secret number is: {}"
,
secret_number
);
loop
{
// Get the value from inside the Ok, else print the error
let
guess
=
match
get_input
()
{
Ok
(
num
)
=>
num
,
...
...
@@ -44,20 +43,20 @@ fn main() {
for
x
in
attempt_history
{
println!
(
"{:?}"
,
x
);
}
println!
(
"Since the HashMap does not push things onto a heap like
the Vec-type does, it will iterate over and print in the order items are found"
);
println!
(
"Since the HashMap does not push things onto a heap like
the Vec-type does, it will iterate over and print in the order items are found"
);
break
;
}
}
println!
(
"Attempts so far: {}
\n
"
,
tries_counter
);
}
}
fn
get_input
()
->
Result
<
u32
,
String
>
{
let
mut
text_input
=
String
::
new
();
println!
(
"Please input your guess."
);
...
...
@@ -66,8 +65,7 @@ fn get_input() -> Result<u32, String> {
Instead of using the expect,
save and return potential error
*/
let
input
=
io
::
stdin
()
.read_line
(
&
mut
text_input
);
let
input
=
io
::
stdin
()
.read_line
(
&
mut
text_input
);
match
input
{
Ok
(
_
)
=>
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment