el single placeholder es utilizado cuando se quiere imprimir un valor único.
fn main() {
println!("Number: {}", 1);
}
Multiple placeholders
podemos usar múltiples placeholders dentro de la macro println!().
el número de placeholders debe ser igual el número de valores a imprimir.
fn main() {
println!("{} con {} company", "Aprendiendo", "Cuadros");
}
Argumentos posicionales
los argumentos posicionales especifica la posición de los valores en la macro.
la lista de valores puede tener cualquier orden.
un valor puede ser utilizado cualquier numero de veces.
fn main() {
println!("Enhance your coding skills from {0} courses. {0} courses are very {1}", "Educative", "interactive");
}
Comentarios
Rust tiene dos maneras de hacer comentarios
Comentarios en línea
para comentar una línea de código debe comenzar por doble slash //
// Writing a Rust program
fn main() {
//The line comment is the recommended comment style
println!("This is a line comment!"); // print hello World to the screen
}
Comentario de bloque
el texto debe estar encerrado dentro de /*...*/
fn main() {
/*
The block comment is extremely useful for temporarily disabling
a large chunk of code. /* Block comments can also be /* nested, */ */
To comment a large block just write in between /* text */
*/
println!("This is a line comment!"); // print hello World to the screen
}
Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.
Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.
Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.
A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!
On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.
Top comments (0)