organizado en carpetas
This commit is contained in:
8
curso_tinchicusls/enums/Cargo.toml
Normal file
8
curso_tinchicusls/enums/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "enums"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
32
curso_tinchicusls/enums/src/main.rs
Normal file
32
curso_tinchicusls/enums/src/main.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
enum Numerado1 {
|
||||
TipoTuple(f32, i32, String),
|
||||
TipoStruct { var1: i32, var2: f32 },
|
||||
StructTuple(i32),
|
||||
Variable,
|
||||
}
|
||||
|
||||
enum Numerado2 {
|
||||
TipoTuple(f32, i32, String),
|
||||
TipoStruct { var1: i32, var2: f32 },
|
||||
StructTuple(i32),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut texto1 = "".to_owned();
|
||||
let mut texto2 = "".to_owned();
|
||||
let mut num1 = 0f32;
|
||||
|
||||
let valor = Numerado1::TipoTuple(3.14, 1, "Hola".to_owned());
|
||||
let valor2 = Numerado2::TipoTuple(3.14, 0, "Mundo".to_owned());
|
||||
|
||||
if let Numerado1::TipoTuple(f, i, s) = valor {
|
||||
texto1 = s;
|
||||
num1 = f;
|
||||
}
|
||||
|
||||
if let Numerado2::TipoTuple(f, i, s) = valor2 {
|
||||
texto2 = s;
|
||||
}
|
||||
|
||||
println!("{}, {}! del hombre {}", texto1, texto2, num1)
|
||||
}
|
||||
Reference in New Issue
Block a user