organizado en carpetas
This commit is contained in:
1
curso_tinchicusls/hola_mundo/.gitignore
vendored
Normal file
1
curso_tinchicusls/hola_mundo/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
8
curso_tinchicusls/hola_mundo/Cargo.toml
Normal file
8
curso_tinchicusls/hola_mundo/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "hola_mundo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
50
curso_tinchicusls/hola_mundo/src/main.rs
Normal file
50
curso_tinchicusls/hola_mundo/src/main.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
/// Statics, son como constantes globales
|
||||
static H: i32 = 21;
|
||||
|
||||
/// Main
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
// si no se especifica es inmutable
|
||||
entero();
|
||||
enteromutable();
|
||||
// unsignet ocupa menos espacio en memoria
|
||||
signet();
|
||||
unsignet();
|
||||
// const no se pueden modificar
|
||||
constante();
|
||||
//static declarada fuera
|
||||
println!("{H}");
|
||||
// castear (parsear)
|
||||
castear(8);
|
||||
}
|
||||
|
||||
fn entero() {
|
||||
let x = 1;
|
||||
println!("{x}");
|
||||
}
|
||||
|
||||
fn enteromutable() {
|
||||
let mut x = 1;
|
||||
x = x + 3;
|
||||
println!("{x}");
|
||||
}
|
||||
|
||||
fn signet() {
|
||||
let sig: i32 = 2048;
|
||||
println!("{sig}");
|
||||
}
|
||||
|
||||
fn unsignet() {
|
||||
let unsig: u32 = 2048;
|
||||
println!("{unsig}");
|
||||
}
|
||||
|
||||
fn constante() {
|
||||
const PI: f32 = 3.14159265;
|
||||
println!("{PI}");
|
||||
}
|
||||
|
||||
fn castear(a: i32) {
|
||||
let valor_final = a as u32;
|
||||
println!("{valor_final}");
|
||||
}
|
||||
Reference in New Issue
Block a user