format
This commit is contained in:
@@ -9,4 +9,5 @@ https://tinchicus.com/2022/09/26/rust-listado-del-curso-inicial/
|
||||
- https://tinchicus.com/2022/06/10/rust-slice/ (slices)
|
||||
- https://tinchicus.com/2022/06/13/rust-pasando-valores/ (porvalor y porreferencia)
|
||||
- https://tinchicus.com/2022/06/14/rust-la-libreria-std/
|
||||
- https://tinchicus.com/2022/06/15/rust-println/ (println)
|
||||
- https://tinchicus.com/2022/06/15/rust-println/ (println)
|
||||
- https://tinchicus.com/2022/06/16/rust-format/ (format)
|
||||
8
format/Cargo.toml
Normal file
8
format/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "format"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
23
format/src/main.rs
Normal file
23
format/src/main.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let mut visual = format!("{} {}", 23, 89);
|
||||
println!("{}", visual);
|
||||
visual = format!("{} {1} {} {0}", "Hola", "Mundo");
|
||||
println!("{}", visual);
|
||||
visual = format!("{t} {a} {b} {a}", a = "Hola", b = "Mundo", t = 23);
|
||||
println!("{}", visual);
|
||||
visual = format!("{:.4}", 3.1415927);
|
||||
println!("{}", visual);
|
||||
|
||||
let v1 = format!("{:.3}", 3.1415927);
|
||||
let v2 = format!("{:b}", 55);
|
||||
let v3 = format!("{:+}!", 5);
|
||||
let v4 = format!("{:x}", 95);
|
||||
let v5 = format!("{:#x}", 95);
|
||||
|
||||
println!("{}", v1);
|
||||
println!("{}", v2);
|
||||
println!("{}", v3);
|
||||
println!("{}", v4);
|
||||
println!("{}", v5);
|
||||
}
|
||||
Reference in New Issue
Block a user