<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Hello-World on Semonan Book</title><link>https://semonan.com/en/tags/hello-world/</link><description>Recent content in Hello-World on Semonan Book</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 29 Sep 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://semonan.com/en/tags/hello-world/rss.xml" rel="self" type="application/rss+xml"/><item><title>Install and Hello world</title><link>https://semonan.com/en/book/programming/rust/install-hello-world/</link><pubDate>Sun, 29 Sep 2024 00:00:00 +0000</pubDate><guid>https://semonan.com/en/book/programming/rust/install-hello-world/</guid><description>&lt;h1 id="install-rust-and-print-hello-world"&gt;Install Rust and Print Hello world&lt;a class="anchor" href="#install-rust-and-print-hello-world"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;h2 id="install-rust"&gt;Install Rust&lt;a class="anchor" href="#install-rust"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Download and run the installation program from the official Rust website.&lt;br&gt;
The installation process is simple.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rust download : &lt;a href="https://www.rust-lang.org/tools/install" rel="noopener noreferrer" target="_blank"&gt;&lt;code&gt;https://www.rust-lang.org/tools/install&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="hello-world"&gt;Hello world&lt;a class="anchor" href="#hello-world"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s create a program that prints a simple message.&lt;br&gt;
I create a file named &lt;code&gt;code1.rs&lt;/code&gt; in the path &lt;code&gt;D:\works\rust\practice1&lt;/code&gt;, and write the following code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-rust" data-lang="rust"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="fm"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;Hello, semonan.com&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Rust starts with &lt;code&gt;main()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Functions are created using the &lt;code&gt;fn&lt;/code&gt; keyword.&lt;/li&gt;
&lt;li&gt;Messages can be printed using &lt;code&gt;println!(&amp;quot;~~~&amp;quot;);&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;!&lt;/code&gt; in &lt;code&gt;println!()&lt;/code&gt; indicates that a Rust Macro is being invoked.&lt;/li&gt;
&lt;li&gt;Rust uses 4 spaces instead of a tab, so there are 4 spaces before &lt;code&gt;println!()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A line of code like &lt;code&gt;println!(&amp;quot;~~~&amp;quot;);&lt;/code&gt; ends with &lt;code&gt;;&lt;/code&gt;. (There are cases where it does not end with &lt;code&gt;;&lt;/code&gt; syntactically, so use it appropriately depending on the situation.)&lt;br&gt;
 &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s compile the source code. &lt;br&gt;
The compiler for Rust is &lt;code&gt;rustc&lt;/code&gt;.&lt;br&gt;
To compile, type the command &lt;code&gt;rustc code1.rs&lt;/code&gt; in the directory where the source code file is located.&lt;br&gt;
&lt;img src="https://semonan.com/images/book/programming/rust/install-hello-world/compile.png" alt="" width="450"&gt;&lt;/p&gt;</description></item></channel></rss>