Now let us write a simple Rust program. Now, launch Notepad, and enter the following code in it:
fn main()
println!("Hello, world!");
Hello, world!
main(): The first line of code in any Rust executable is always the main() function. Curly braces{} encapsulate the main() function. The function main() does not return any value and does not take any parameters.
println!: It’s a macro in Rust. It doesn’t contain ‘!’ if it calls the method.
“Hello World” : The string is sent to println! as an argument, and the result is printed to the console.
1. Open the notepad document and enter the code there.
2. Save the file using the.rs suffix.
3. Launch the Command Prompt.
4. Configure the directory’s path. Assume D Drive is where the project is situated.
5. Use the rustc command to compile the aforementioned program.
6. Lastly, use the command filename.exe to launch the software.
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.