tuple struct
This commit is contained in:
@@ -28,3 +28,4 @@
|
|||||||
- https://tinchicus.com/2022/07/12/rust-memoria-estatica/ (ejemplo03)
|
- https://tinchicus.com/2022/07/12/rust-memoria-estatica/ (ejemplo03)
|
||||||
- https://tinchicus.com/2022/07/13/rust-struct/ (estructura)
|
- https://tinchicus.com/2022/07/13/rust-struct/ (estructura)
|
||||||
- https://tinchicus.com/2022/07/14/rust-struct-en-multiples-archivos/ (estructura2)
|
- https://tinchicus.com/2022/07/14/rust-struct-en-multiples-archivos/ (estructura2)
|
||||||
|
- https://tinchicus.com/2022/07/15/rust-tuple-struct/ (nuevotipo)
|
||||||
|
|||||||
8
nuevotipo/Cargo.toml
Normal file
8
nuevotipo/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "nuevotipo"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
11
nuevotipo/src/main.rs
Normal file
11
nuevotipo/src/main.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// tuple-struct;
|
||||||
|
struct MiPi(f32);
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// creamos objeto del tipo MiPi
|
||||||
|
let mi_pi = MiPi(22f32 / 7f32);
|
||||||
|
println!("mi_pi = {:?}", mi_pi.0);
|
||||||
|
// asignación de patrón de tipo nuevo
|
||||||
|
let MiPi(pi) = mi_pi;
|
||||||
|
println!("pi = {}", pi);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user