~eduardo_quiros/rust_guessing_game

becb5f0a592896cbddbfe426889c4291b3419160 — Eduardo Quiros 8 months ago master
start project
5 files changed, 31 insertions(+), 0 deletions(-)

A .gitignore
A Cargo.lock
A Cargo.toml
A README.md
A src/main.rs
A  => .gitignore +1 -0
@@ 1,1 @@
/target

A  => Cargo.lock +5 -0
@@ 1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "guessing_game"
version = "0.1.0"

A  => Cargo.toml +9 -0
@@ 1,9 @@
[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Eduardo Quiros <eduardo@eduardoquiros.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

A  => README.md +3 -0
@@ 1,3 @@
# Guessing Game

Small excersice on using Rust as a language.

A  => src/main.rs +13 -0
@@ 1,13 @@
use std::io; // Importa la biblioteca de I/O

fn main() {
    println!("Guess the number!"); // Imprime texto
    println!("Please input your guess.");

    let mut guess = String::new(); // Declara una variable mutable y se inicia como String

    io::stdin().read_line(&mut guess) // Lee el input del usuario
        .expect("Failed to read line"); // Ocurre en caso de que la lectura falle. Imagino que es similar a "catch" en java

    println!("You guessed: {}", guess); // Imprime el texto, reemplazando las llaves por la variable llamada
}