Rust - Hello, World!

0

At first

This article is about Rinrin who has a lack of memory in the brain. I wrote it for when I forgot the Rust specification while learning. Therefore, the information may be outdated or incorrect. In such a case, if you say it, maybe fix it ( 'ω') Do your own research on Rust environment construction, project creation, etc.

Contents ♪

Hello, World!

Hello, World! Do as follows

fn main() {
    println!("Hello, World!");
}

If you throw a character you want to output to the println! macro, it will output it By the way, this guy is not a function, it's a macro. Executing above prints Hello, World! Also, line breaks are performed even if multiple executions are executed.

fn main() {
    println!("Hello, ");
    println!("World!");
}

When I run this thing, the following is output

Hello, 
 World!

print! macros

If you use this thing, you will not get line breaks

fn main() {
    print!("Hello, ");
    print!("World!");
}

When executed, it prints Hello, World!

Summary

  • For output of strings, etc., use println! macro or print! macro.
  • The println! macro breaks every time you use it.
  • print! macros work without line breaks
Share:
0
Author by

仆ば优秀の人材た, 信赖ずゑとよい。

Updated on January 27, 2022