cierre
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
|
## https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
|
||||||
|
|
||||||
- https://tinchicus.com/2022/06/01/rust-usando-a-cargo/ (hola_mundo)
|
- https://tinchicus.com/2022/06/01/rust-usando-a-cargo/ (hola_mundo)
|
||||||
- https://tinchicus.com/2022/06/03/rust-strings/ (cadenas)
|
- https://tinchicus.com/2022/06/03/rust-strings/ (cadenas)
|
||||||
@@ -17,3 +17,4 @@ https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
|
|||||||
- https://tinchicus.com/2022/06/22/rust-if/ (condicion)
|
- https://tinchicus.com/2022/06/22/rust-if/ (condicion)
|
||||||
- https://tinchicus.com/2022/06/23/rust-match/ (coincidir)
|
- https://tinchicus.com/2022/06/23/rust-match/ (coincidir)
|
||||||
- https://tinchicus.com/2022/06/24/rust-funciones-y-metodos/ (ejemplo01)
|
- https://tinchicus.com/2022/06/24/rust-funciones-y-metodos/ (ejemplo01)
|
||||||
|
- https://tinchicus.com/2022/06/27/rust-closures/ (cierre)
|
||||||
8
cierre/Cargo.toml
Normal file
8
cierre/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "cierre"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
39
cierre/src/main.rs
Normal file
39
cierre/src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
fn rutina_ejercicio(i: u32, a: u32) {
|
||||||
|
let cierre = |num| {
|
||||||
|
println!("Recalculando...");
|
||||||
|
thread::sleep(Duration::from_secs(2));
|
||||||
|
num
|
||||||
|
};
|
||||||
|
if i < 25 {
|
||||||
|
println!("Hoy haz {} sentadillas", cierre(i));
|
||||||
|
println!("Despues haz {} sentadillas", cierre(i));
|
||||||
|
} else {
|
||||||
|
if a == 3 {
|
||||||
|
println!("Descansa un poco y recuerda hidratarte");
|
||||||
|
} else {
|
||||||
|
println!("Hoy corre por {} minutos", cierre(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let valor_especificado = 27;
|
||||||
|
let numero_al_azar = 5;
|
||||||
|
|
||||||
|
rutina_ejercicio(valor_especificado, numero_al_azar);
|
||||||
|
|
||||||
|
// ejemplo creado por mi
|
||||||
|
|
||||||
|
let imprime_algo = |texto| {
|
||||||
|
println!("WTF!!!!!");
|
||||||
|
texto
|
||||||
|
};
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Vamos a imprimir el texto....{}",
|
||||||
|
imprime_algo("Mis cojones mangas 3")
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -10,5 +10,5 @@ impl Perro {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let perro = Perro::nuevo(98, 87);
|
let perro = Perro::nuevo(98, 87);
|
||||||
println!("{} {}", perro.edad, perro.peso)
|
println!("{} {}", perro.edad, perro.peso);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user