Created
January 26, 2024 03:56
-
-
Save gusdelact/551fc1e20f478d7a5d31368855892e56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://t.me/RustMX | |
*/ | |
use std::collections::HashMap; | |
fn d1(x:i32)->Result<i32,u32> | |
{ | |
if x >0 | |
{ | |
Ok(x + 5) | |
} | |
else | |
{ | |
Err(500) | |
} | |
} | |
fn main() | |
{ | |
let mut vec01:Vec<i32> = Vec::new(); | |
vec01.push(2); | |
for i in 101..110 | |
{ | |
vec01.push(i); | |
} | |
println!("{:?}",vec01); | |
println!("{}",vec01.len()); | |
let mut hsh1: HashMap<String,i32> = HashMap::new(); | |
hsh1.insert(String::from("CUTG"),1000); | |
hsh1.insert(String::from("TOMD"),2000); | |
hsh1.insert(String::from("CADF"),3000); | |
println!("{:?}",hsh1); | |
let v1= hsh1.get("CUTG"); | |
println!("{:?}",v1); | |
match v1 | |
{ | |
Some(x)=>println!("{:?}",x), | |
None => println!("No existe el contribuyente") | |
} | |
let v2= hsh1.get("DUPA"); | |
println!("{:?}",v2); | |
match v2 | |
{ | |
Some(x)=>println!("{:?}",x), | |
None => println!("No existe el contribuyente") | |
} | |
let v3=d1(2); | |
println!("{:?}",v3); | |
match v3 | |
{ | |
Ok(x) => println!("{}",x+1), | |
Err(_) => println!("Aprende a usarme") | |
} | |
let v4=d1(-1); | |
println!("{:?}",v4); | |
match v4 | |
{ | |
Ok(x) => println!("{}",x+1), | |
Err(_) => println!("Aprende a usarme") | |
} | |
panic!("a correr!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment