gh-pages
Dhghomon 4 years ago
parent ea7ef07208
commit 4f3832064f

@ -164,6 +164,7 @@
<div id="content" class="content">
<main>
<h2><a class="header" href="#type-inference" id="type-inference">Type inference</a></h2>
<p><a href="https://youtu.be/q1D2vpy3kEI">See this chapter on YouTube</a></p>
<p>Type inference means that if you don't tell the compiler the type, but it can decide by itself, it will decide. The compiler always needs to know the type of the variables, but you dont always need to tell it. Actually, usually you don't need to tell it. For example, for <code>let my_number = 8</code>, <code>my_number</code> will be an <code>i32</code>. That is because the compiler chooses i32 for integers if you don't tell it. But if you say <code>let my_number: u8 = 8</code>, it will make <code>my_number</code> a <code>u8</code>, because you told it <code>u8</code>.</p>
<p>So usually the compiler can guess. But sometimes you need to tell it, for two reasons:</p>
<ol>

@ -164,6 +164,7 @@
<div id="content" class="content">
<main>
<h2><a class="header" href="#printing-hello-world" id="printing-hello-world">Printing 'hello, world!'</a></h2>
<p>See this chapter on YouTube: <a href="https://youtu.be/yYlPHRl2geQ">Video 1</a>, <a href="https://youtu.be/DTCSfBJJZb8">Video 2</a></p>
<p>When you start a new Rust program, it always has this code:</p>
<pre><pre class="playground"><code class="language-rust">fn main() {
println!(&quot;Hello, world!&quot;);

@ -511,6 +511,7 @@ Slice2 is 7 bytes.
Slice2 is 7 bytes but only 3 characters.
</code></pre>
<h2><a class="header" href="#type-inference" id="type-inference">Type inference</a></h2>
<p><a href="https://youtu.be/q1D2vpy3kEI">See this chapter on YouTube</a></p>
<p>Type inference means that if you don't tell the compiler the type, but it can decide by itself, it will decide. The compiler always needs to know the type of the variables, but you dont always need to tell it. Actually, usually you don't need to tell it. For example, for <code>let my_number = 8</code>, <code>my_number</code> will be an <code>i32</code>. That is because the compiler chooses i32 for integers if you don't tell it. But if you say <code>let my_number: u8 = 8</code>, it will make <code>my_number</code> a <code>u8</code>, because you told it <code>u8</code>.</p>
<p>So usually the compiler can guess. But sometimes you need to tell it, for two reasons:</p>
<ol>
@ -597,6 +598,7 @@ Slice2 is 7 bytes but only 3 characters.
}
</code></pre></pre>
<h2><a class="header" href="#printing-hello-world" id="printing-hello-world">Printing 'hello, world!'</a></h2>
<p>See this chapter on YouTube: <a href="https://youtu.be/yYlPHRl2geQ">Video 1</a>, <a href="https://youtu.be/DTCSfBJJZb8">Video 2</a></p>
<p>When you start a new Rust program, it always has this code:</p>
<pre><pre class="playground"><code class="language-rust">fn main() {
println!(&quot;Hello, world!&quot;);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save