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
}
Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.
Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.
Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.
A simple “thank you” goes a long way—express your gratitude below in the comments!
Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.
Top comments (0)