Compare commits
2 Commits
bf9b2271d0
...
327e1279fc
| Author | SHA1 | Date | |
|---|---|---|---|
| 327e1279fc | |||
| a077149208 |
8
coincidir/Cargo.toml
Normal file
8
coincidir/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "coincidir"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
46
coincidir/src/main.rs
Normal file
46
coincidir/src/main.rs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
fn main() {
|
||||||
|
let booleano = false;
|
||||||
|
|
||||||
|
let binario;
|
||||||
|
match booleano {
|
||||||
|
false => binario = 0,
|
||||||
|
true => binario = 1,
|
||||||
|
}
|
||||||
|
println!("{} -> {}", booleano, binario);
|
||||||
|
|
||||||
|
let booleano = !booleano;
|
||||||
|
let binario = match booleano {
|
||||||
|
false => 0,
|
||||||
|
true => 1,
|
||||||
|
};
|
||||||
|
println!("{} -> {}", booleano, binario);
|
||||||
|
|
||||||
|
let x = 1;
|
||||||
|
|
||||||
|
match x {
|
||||||
|
1 | 2 | 3 => println!("Works"),
|
||||||
|
_ => println!("Noooo"),
|
||||||
|
}
|
||||||
|
|
||||||
|
match x {
|
||||||
|
1..=10 => println!("Works to"),
|
||||||
|
_ => println!("Noooo"),
|
||||||
|
}
|
||||||
|
|
||||||
|
let y = 'G';
|
||||||
|
|
||||||
|
match y {
|
||||||
|
'A'..='Z' => println!("Works to"),
|
||||||
|
_ => println!("Noooo"),
|
||||||
|
}
|
||||||
|
|
||||||
|
match y {
|
||||||
|
p @ 'A'..='Z' => println!("{}", p),
|
||||||
|
_ => println!("Noo"),
|
||||||
|
}
|
||||||
|
|
||||||
|
match y {
|
||||||
|
p @ 'A'..='F' | p @ 'G'..='Z' => println!("{}", p),
|
||||||
|
_ => println!("Noo"),
|
||||||
|
}
|
||||||
|
}
|
||||||
8
ejemplo01/Cargo.toml
Normal file
8
ejemplo01/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "ejemplo01"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
14
ejemplo01/src/main.rs
Normal file
14
ejemplo01/src/main.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
struct Perro {
|
||||||
|
peso: i32,
|
||||||
|
edad: i32,
|
||||||
|
}
|
||||||
|
impl Perro {
|
||||||
|
fn nuevo(a: i32, b: i32) -> Perro {
|
||||||
|
Perro { peso: a, edad: b }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let perro = Perro::nuevo(98, 87);
|
||||||
|
println!("{} {}", perro.edad, perro.peso)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user