Common Programming Concepts in Rust

Let's Get Rusty
31 Jan 202114:33

Summary

TLDRこの動画はRustプログラミング言語についての教育チャンネル「Let's Get Rusty」の第3回目の動画です。ホストのBogdanは、基本的なプログラミング概念を紹介しています。変数の不変性と可変性、定数、型注釈、シャドウイング、スカラー型と複合型のデータ型、関数の定義と呼び出し、制御フローの構造(if文、ループ)、そしてコメントの使い方について学ぶことができます。特に、Rustにおける変数の不変性と定数の違い、配列の固定長性、関数の戻り値の指定方法、if-else文の使い方、そしてループの種類について詳しく解説しています。この動画はRustを学びたい人にとって、非常に役立つ内容となっています。

Takeaways

  • 📌 Rust は変数の不変性をデフォルトでサポートしています。
  • 🔄 変数を再代入するには、`let` キーワードの後に `mut` を追加する必要があります。
  • 🔒 `const` キーワードを使用して定数を定義し、変更できない値を作成できます。
  • 📈 Rust は整数、浮動小数点数、ブール値、文字の4つの主要なスカラーデータ型をサポートしています。
  • 🔢 Rust の整数型には、符号付きと符号なし、および異なるビットサイズ(8, 16, 32, 64, 128ビット)があります。
  • 🔄 Rust は整数オーバーフローを検出し、デバッグビルドではパニックを起こし、リリースビルドでは2の補数巻戻しを行います。
  • 📊 Rust はタプル型と配列型を備えており、タプルは異なる型の固定サイズのデータグループを表し、配列は固定長のデータ構造です。
  • 🔧 Rust の関数は `fn` キーワードを使用して宣言され、引数を受け取ることができます。
  • 🔄 Rust の制御フローには if 文、while ループ、for ループがあります。
  • 📝 Rust には1行コメントとブロックコメントがあり、コードの説明や無効化に使用されます。
  • 🔄 Rust 関数は値を返すことができます。最後の式は省略可能で、関数の戻り値として使用されます。

Q & A

  • Rust言語における変数の初期値設定はどのように行われますか?

    -Rustでは、変数は`let`キーワードを使って初期値を設定します。例えば、`let x = 5;`のように宣言と同時に初期値を設定できます。

  • Rustにおける不変変数と可変変数の違いは何ですか?

    -Rustでは、変数はデフォルトで不変(immutable)です。不変変数は一度値が設定されると、その後変更することができません。可変変数を作り、値を再代入するには、`let mut`を使用します。

  • Rustで定数を定義する方法は何ですか?

    -Rustで定数を定義するには`const`キーワードを使用します。例えば、`const SUBSCRIBER_COUNT: u32 = 100_000;`のように、型注釈も必要です。定数は変更できないため、安全にグローバルにアクセスできます。

  • Rustにおけるシャドウイングとは何ですか?

    -シャドウイングは、既存の変数名を使って新しい変数を宣言する機能です。これにより、前の変数が新しい変数によって遮られます。シャドウイングされた変数は、前の変数とは型が異なる場合もあります。

  • Rustのスカラーデータ型にはどのようなものがありますか?

    -Rustのスカラーデータ型には、整数(整数型)、浮動小数点数(浮動小数点型)、ブール値(boolean型)、文字(character型)の4つがあります。

  • Rustのタプル型はどのように定義されるか?タプルの値を取得する方法は?

    -タプル型は、異なる型のデータを含む固定サイズの配列のようなものです。定義は`(データ1, データ2, ...)`の形式で行われます。タプルの値を取得には、解構(destructuring)またはドット記法(dot notation)を使用できます。

  • Rustの配列はどのように宣言され、アクセスされるか?

    -配列は`[データ1, データ2, ...]`の形式で宣言され、固定長です。配列の要素にアクセスするには、ブラケット記法(`配列名[index]`)を使用します。ただし、範囲外のインデックスにアクセスしようとすると、境界外例外が発生します。

  • Rustの関数はどのように定義されるか?

    -関数は`fn`キーワードを使って定義されます。関数名はスネークケース(snake_case)で記述し、引数は括弧内に型注釈付きの名前を指定します。

  • Rustの制御フローにおいて、if文はどのように使われますか?

    -Rustのif文は、条件が真である場合にコードブロックを実行します。else ifとelseブロックも使用でき、条件は明示的にブール値でなければなりません。

  • Rustのループにはどのような種類がありますか?

    -Rustのループには、`loop`、`while`、および`for`の3種類があります。`loop`は無条件にループし、`while`は条件が真である間ループし、`for`はコレクションを反復処理するために使用されます。

  • Rustのコメントにはどのような種類がありますか?

    -Rustには、単一行コメント(`//`)とブロックコメント(`/* ... */`)の2種類があります。また、文書コメント(`///`)もありますが、これは別の用途に使われます。

  • Rustの関数から値を返す方法は?

    -Rustの関数は、`return`文を使って値を返すことができます。また、関数の最後の式は暗黙的に返されます。関数の戻り値の型は、関数定義の後ろに指定することができます。

Outlines

00:00

📚 欢迎来到Rust编程世界

本视频介绍了Rust编程语言的基础知识,包括变量、基本类型、函数、控制流和注释。首先,我们创建了一个名为'variables'的新Cargo项目,并讨论了Rust中变量的不可变性。通过创建一个名为'x'的变量并尝试重新赋值,我们展示了Rust中的错误处理。接着,我们学习了如何使变量可变,以及如何创建常量值。此外,还探讨了变量阴影的概念,以及如何通过类型注解来定义常量。最后,我们讨论了数据类型,包括标量数据类型(整数、浮点数、布尔值和字符)和复合数据类型(元组和数组),以及如何处理整数溢出。

05:00

🔢 Rust中的数据类型和函数

这一部分深入探讨了Rust中的标量数据类型,包括整数、浮点数、布尔值和字符。我们了解了Rust中整数的不同表示方式,以及如何处理整数溢出。浮点数部分介绍了默认的64位双精度浮点数。布尔值和字符类型也得到了简要介绍。接下来,我们讨论了复合数据类型,如元组和数组,以及如何从这些类型中获取值。此外,还介绍了函数的声明和调用,以及如何传递参数。最后,我们学习了表达式和语句的区别,以及如何在函数中返回值。

10:01

🔄 Rust的控制流和循环

这一段落介绍了Rust中的控制流,包括if语句和三种循环类型:无限循环(loop)、while循环和for循环。我们学习了如何在if语句中使用条件判断,以及如何在let语句中使用if-else表达式。循环部分,我们讨论了如何使用break语句来控制循环的执行。还介绍了如何从循环中返回值,以及如何使用for循环来遍历集合。最后,我们了解了Rust中的注释类型,包括单行注释和块注释。

Mindmap

Keywords

💡Rust

Rustは、このビデオの中心となるプログラミング言語です。ビデオでは、Rustの基本的な概念や機能について学ぶことができます。Rustは、安全性とパフォーマンスを兼ね備えたシステムプログラミング言語であり、CやC++の欠点を改善することを目的としています。

💡Variables

変数は、プログラミングにおいてデータを保存するための名前付きコンテナです。Rustでは、変数はデフォルトで不変(immutable)であり、値を再代入する場合、その変数をミュータブルに設定する必要があります。

💡Immutability

不変性とは、オブジェクトの状態が変更されないことを意味します。Rustでは、不変な変数を宣言することで、プログラムの安全性を高めることができます。

💡Constants

定数は、一度値が割り当てられた後、変更できない変数です。Rustでは、定数を使用することで、特定の値をプログラム全体で一貫して使用することができます。

💡Shadowing

シャドウイングは、既存の変数名を使用して新しい変数を宣言することを指します。これにより、前の変数は新しい変数によって隠蔽されます。シャドウイングは、変数のタイプを変更したり、同じ名前の変数を異なるコンテキストで使用するために役立ちます。

💡Data Types

データ型は、変数や関数の引数、戻り値が持つデータの種類を定義します。Rustには、スカラー型(整数、浮動小数点数、ブール値、文字)と複合型(タプル、配列)があります。

💡Control Flow

コントロールフローは、プログラムの実行順序を制御する方法を指します。Rustでは、if文、else if文、else文、およびループ(loop、while、for)を使用して、条件に基づいてコードの実行を制御します。

💡Functions

関数は、コードを再利用可能な単位として定義された一連のステートメントです。Rustでは、`fn`キーワードを使用して関数を宣言し、引数を渡したり、戻り値を返すことができます。

💡Comments

コメントは、プログラムのコードを説明するために使用されるテキストです。Rustでは、単一行コメントとブロックコメントを使用して、コードの理解を助けることができます。

💡Tuples

タプルは、固定サイズの配列のようなデータ構造で、異なる型の値のグループを保持できます。Rustのタプルは、カッコで定義され、値を取得するためにデストラクチャリングまたはドット表記を使用できます。

💡Arrays

配列は、同じ型の値の連続したリストです。Rustの配列は、固定長であり、角括弧`[]`を使用して定義します。配列の要素にアクセスするには、インデックスを使用します。

Highlights

Rust programming language tutorial

Chapter three covers basic programming concepts

Variables in Rust are immutable by default

To make a variable mutable, use the 'mut' keyword

Constants are declared with the 'const' keyword and must be type annotated

Constants cannot be mutated and must be set to constant expressions

Shadowing allows re-declaring a variable with the same name

Scalars represent single values, while compounds represent groups

Rust has four main scalar data types: integers, floating points, booleans, and characters

Integers in Rust can be signed or unsigned and have various sizes

Rust prevents integer overflow by performing two's complement wrapping

Floating point numbers are 64-bit double precision by default

Tuples are fixed-size arrays of different types

Arrays in Rust are fixed length and start at index zero

Functions in Rust are declared with the 'fn' keyword and follow snake case naming convention

Functions can take parameters and return values

Control flow in Rust includes if statements and loops

Loops in Rust include 'loop', 'while', and 'for' loops

Comments in Rust include single line, block, and documentation comments

Chapter three summary: variables, basic types, functions, comments, and control flow

Transcripts

play00:00

welcome back to let's get rusty my name

play00:02

is bogdan and this channel is

play00:03

all about the rust programming language

play00:05

if that sounds interesting to you

play00:07

hover over that subscribe button and

play00:09

give it a high five last time we went

play00:10

over chapter two of the book and if you

play00:12

haven't seen that video

play00:13

make sure to check it out in this video

play00:15

we're going over chapter three

play00:16

in which we'll learn basic programming

play00:18

concepts such as variables

play00:20

basic types functions control flow and

play00:23

comments with that

play00:24

let's get started all right i went ahead

play00:25

and created a new cargo project i assume

play00:28

everyone knows how to do this but if you

play00:29

don't go ahead and watch my previous

play00:31

videos and you can name this project

play00:33

whatever you'd like i chose to name

play00:35

mines variables

play00:37

now the first thing we're going to do is

play00:38

start off by talking about variables

play00:40

and immutability you might remember from

play00:42

previous videos that variables are

play00:44

immutable by default

play00:46

in rust so to prove that out let's

play00:48

create a new variable called

play00:50

x and we'll set that equal to five

play00:55

and then we'll print the variable

play00:58

next we'll reassign it to something else

play01:01

this case

play01:01

six and we'll print it out again now i

play01:04

didn't even have to compile this

play01:06

to get an error because i have a

play01:07

language server running so if i hover

play01:09

over the red squigglies i could see that

play01:11

we gave error saying you cannot assign

play01:13

twice to an immutable variable

play01:15

in this case x so let's say we did want

play01:17

to make it immutable all we have to do

play01:19

is

play01:20

type in mu after the let keyword and now

play01:22

we can reassign

play01:23

x and we can go cargo run

play01:28

and we see that x gets printed out as

play01:30

five on the first line

play01:32

and six on the second line or it also

play01:34

has the concept

play01:35

of constant values or values that can

play01:38

never change

play01:39

to create one we'll use the const

play01:40

keyword and here i'll create one for my

play01:43

subscriber count

play01:44

i'll set the type to an unsigned 32-bit

play01:46

integer

play01:47

and make it equal 100 000.

play01:50

we can all dream when declaring

play01:52

constants it's common practice

play01:54

to have the variable name be all

play01:55

uppercase with

play01:57

underscores where there are spaces now

play01:59

you might ask why do we need constants

play02:01

when variables in rest are

play02:02

already immutable by default well there

play02:05

are a few key differences between

play02:07

constants and variables

play02:08

the first is you cannot mutate a

play02:10

constant so for example if i type in mu

play02:13

in front of our constant i get an error

play02:15

here that says

play02:16

const globals cannot be mutable so if

play02:18

you declare a constant you can be sure

play02:20

that it will never be

play02:21

mutated const variables must also be

play02:24

type annotated

play02:25

you can see here our constant is an

play02:27

unsigned 32-bit integer

play02:28

up here we didn't annotate our x

play02:30

variable because rust referred that it

play02:32

was a signed

play02:33

32-bit integer but for constants we have

play02:36

to annotate it constant

play02:37

variables can also only be set to

play02:39

constant expressions

play02:40

for example with our variable x we could

play02:43

have set it to the return value of a

play02:45

function

play02:45

but we cannot set constants to the

play02:47

return value of a function

play02:49

or any value that is computed at runtime

play02:52

lastly here 100 000 might be hard to

play02:54

read luckily rust allows us to make

play02:56

numeric literals

play02:58

more readable by adding an underscore

play03:02

and there we have our constant with a

play03:04

little warning telling us that

play03:05

it's never used which is okay now the

play03:07

last thing i want to talk about

play03:09

on the subject of variables is shadowing

play03:11

shadowing allows you to create a new

play03:13

variable

play03:14

using an existing name for example in

play03:16

our program instead of making

play03:18

x mutable we can remove the mute keyword

play03:20

and then re-declare

play03:21

x here now this first

play03:25

x variable is shadowed by the second x

play03:28

variable

play03:28

this gives us two advantages first we

play03:31

preserve mutability

play03:32

this first x is still immutable and the

play03:35

second x

play03:35

is also immutable secondly we could

play03:38

change types

play03:39

so for example we could take the second

play03:40

variable which is a six and instead of

play03:42

an integer

play03:43

we can make it a string now we can go

play03:45

and run our program

play03:46

and you can see that five is printed for

play03:48

the first x and the string six

play03:50

is printed for the second x next we'll

play03:52

look at data types specifically scalar

play03:55

data types and compound data types

play03:57

scalar data types represent a single

play03:59

value

play04:00

while compound data types represent a

play04:02

group of values

play04:03

first let's talk about scalar data types

play04:06

rust has

play04:07

four main scalar data types which are

play04:09

integers

play04:10

floating point numbers booleans and

play04:13

characters

play04:14

integers are numbers without a

play04:15

fractional component and here i have the

play04:17

rust book pulled up

play04:18

with a table showing you the integer

play04:20

types in rust

play04:22

every integer has a length and it could

play04:24

either be signed

play04:25

or unsigned signed integers could be

play04:27

positive or negative numbers and

play04:28

unsigned integers can only be

play04:30

positive numbers integers could be 8

play04:32

bits in size 16 bits 32 bits

play04:35

64 bits 128 bits or arc which depends on

play04:39

the architecture

play04:40

usually either 64 or 32-bit rust

play04:43

defaults integers to assign a 32-bit

play04:46

integer

play04:47

and as you can see we have different

play04:48

ways of representing integers

play04:50

decimal hex octal binary or byte

play04:54

lastly let's talk about integer overflow

play04:56

here i have an

play04:57

8-bit unsigned integer which can hold a

play05:00

max value

play05:01

of 255. if i try to set this to a number

play05:03

greater than 255 in debug builds

play05:06

rust will panic and in release builds

play05:08

rust will perform two's complement

play05:10

wrapping

play05:11

which means values greater than the

play05:12

maximum will wrap around

play05:14

back to the minimum values so 256 would

play05:17

become zero

play05:18

257 would become one also if you have a

play05:21

language server running

play05:22

and you try to change this to 256 you'll

play05:25

get an

play05:25

error warning you of the overflow rust

play05:27

also supports floating point numbers

play05:29

which are numbers with decimal points

play05:31

and as you can see the default is a 64

play05:33

bit double precision

play05:34

floating point number and of course we

play05:36

could do all our basic numeric

play05:38

operations such as addition subtraction

play05:40

multiplication

play05:41

division and remainder next we have

play05:43

booleans which represent the values true

play05:45

or false and lastly we have the

play05:47

character type which represents a

play05:48

unicode character

play05:50

is written with single quotes and

play05:52

something we'll learn about more

play05:54

in chapter eight next let's talk about

play05:56

compound types which are types that

play05:57

represent a group of values

play05:59

first we have the tuple type which you

play06:01

can think about as a fixed size array

play06:03

of related data that could be of

play06:05

different type here we have a tuple with

play06:07

only two values

play06:08

the first is a string representing a

play06:10

youtube channel name

play06:11

and the second is an integer

play06:13

representing subscriber count

play06:14

tuples are written by using a comma

play06:16

separated list

play06:17

inside of parentheses and you can see

play06:20

here our type

play06:21

is automatically annotated we can get

play06:23

values out of tuples in two ways

play06:25

the first is destructuring and the

play06:27

second is dot notation

play06:28

to destructure a tuple we'll create a

play06:30

new set of variables

play06:31

inside parentheses here we have channel

play06:34

and sub count

play06:35

and we'll set that equal to our tuple

play06:37

setting this equal to our tuple we'll

play06:38

take the first variable

play06:40

and set that equal to the first value in

play06:42

our tuple then it'll take the second

play06:43

value

play06:44

and set that equal to the second value

play06:46

in our tuple we could also get values

play06:48

out of tuples by using the dot notation

play06:50

for example we'll create a new variable

play06:52

called sub count and set that equal to

play06:54

the tuple

play06:55

value one two poles as well as arrays

play06:59

both start at index zero to declare

play07:01

arrays in rust

play07:02

we use a comma separated list but

play07:04

instead of parentheses we use

play07:06

brackets in rust arrays are fixed length

play07:08

if you want something that can change

play07:10

size dynamically

play07:12

you would have to use a vector which

play07:13

we'll talk about more in chapter 8. to

play07:15

access

play07:16

individual values within an array we use

play07:18

the standard bracket syntax here

play07:20

erase could also be declared using this

play07:22

syntax here which says create an array

play07:24

with eight values

play07:25

all set to zero lastly if we try to

play07:27

access an index that's invalid for

play07:30

example here we have a variable

play07:31

x that accesses index three which does

play07:34

not exist

play07:35

we can type cargo run and we see that we

play07:38

get a out of bounds

play07:39

exception rust prevents us from doing

play07:41

something that's memory unsafe and it's

play07:42

able to do this because we know the size

play07:44

of the array

play07:45

next let's talk about functions and rest

play07:47

functions can be declared using the fn

play07:49

keyword

play07:50

so here we'll define a function right

play07:52

underneath main

play07:59

and we'll simply make a print another

play08:01

function rust uses the snake case

play08:03

convention for function names meaning

play08:05

that the function name should be all

play08:06

lowercase

play08:07

and whenever there's a space use an

play08:09

underscore now we can call our new

play08:11

function from main by specifying the

play08:12

function name

play08:13

and parentheses then we'll do cargo run

play08:17

and we can see that our function was

play08:19

called we can also allow our function to

play08:20

take in parameters by specifying the

play08:22

parameter name

play08:23

and its type inside the parentheses we

play08:26

can add multiple parameters by

play08:27

separating them

play08:28

with a comma like so and as you can see

play08:30

we get an error here because our

play08:32

function takes two arguments

play08:33

but we're not passing any so let's pass

play08:36

in some arguments

play08:40

and let's also change our function to

play08:41

print out the values passed in then we

play08:43

can run our program

play08:45

and we see our values printed out in

play08:47

rest we could think about a piece of

play08:48

code as either a statement

play08:50

or an expression statements perform some

play08:52

action but do not return a value

play08:54

whereas expressions return a value as an

play08:56

example inside of my function the print

play08:58

line statements are

play08:59

well statements because they don't

play09:01

return anything here we created a new

play09:03

variable called sum

play09:04

which adds x and y together x plus y

play09:06

here

play09:07

is an expression because we add x and y

play09:10

and return that value

play09:11

in rest we can return values from a

play09:13

function in two ways

play09:15

the first way is to use the return

play09:20

statement

play09:22

here we're returning some and you can

play09:23

see we get an error because the function

play09:25

doesn't have

play09:26

a return type to specify a return type

play09:28

after the parentheses you can add a dash

play09:30

and an arrow and then specify the return

play09:32

type in this case a signed 32-bit

play09:34

integer

play09:35

inside of a function the last expression

play09:37

is implicitly returned

play09:38

so if we want to return sum we can

play09:40

remove the return keyword

play09:42

also for the last expression in the

play09:43

function we omit the semicolon

play09:46

we can simplify this further by removing

play09:48

sum and just returning

play09:50

x plus y then in our main function we

play09:53

can create a new variable called

play09:55

sum and set that equal to the return

play09:57

value of our function

play09:58

then we can print out our value let's

play10:00

run our program and you can see

play10:02

we print out 11 22 and the sum

play10:05

all right now let's talk about control

play10:07

flow first we have

play10:08

if statements and if you've programmed

play10:10

before the syntax should be very

play10:11

familiar

play10:12

you have an if block with a condition

play10:15

and code that executes if that condition

play10:17

is true we can have else if blocks

play10:20

and finally we can have an else block if

play10:22

all the other conditions

play10:23

fail in rest however the condition must

play10:26

be explicitly

play10:27

a boolean so for example if we just try

play10:29

to evaluate number

play10:31

will get an error here we're trying to

play10:32

evaluate an integer

play10:34

but instead we need a bool lastly we can

play10:36

use an if-else statement

play10:38

inside of a let statement for example we

play10:40

have this variable that's called

play10:42

condition

play10:42

we set it to true and then we have a

play10:45

variable called number and we set that

play10:46

to an if-else expression

play10:48

if the condition is true the number is

play10:50

five

play10:51

else the number will be six next we'll

play10:53

talk about the three different types of

play10:55

loops in rust the most basic type of

play10:57

loop we create using the loop

play10:58

keyword what this will do is execute the

play11:01

code inside of the loop until we call

play11:03

break right now we don't call break at

play11:05

all so if i run the program

play11:06

it'll execute forever you can press ctrl

play11:09

c

play11:10

to exit the program we'll go back and

play11:12

add a break statement

play11:14

then we'll run our program again and

play11:16

this time the loop only executes once

play11:18

we can also return values from this type

play11:20

of loop to show how this works let's

play11:22

create a new mutable variable called

play11:24

counter and set it equal

play11:28

to zero then every time we run our loop

play11:31

we'll increment counter

play11:35

next we'll add a if statement to check

play11:37

when counter gets to ten

play11:42

and when it does we'll break out of the

play11:44

loop and return counter

play11:48

then we'll remove our previous break

play11:49

statement adding counter after break

play11:51

will make this loop

play11:52

return counter now we can set the return

play11:54

value to another variable in this case

play11:56

we'll call it result

play12:00

we'll need to add a semicolon to the end

play12:02

of our loop

play12:04

and print out the value now when we run

play12:06

our program

play12:08

we'll get 10 printed out there are two

play12:09

other types of loops and rust the second

play12:11

one is the classic while loop which will

play12:13

execute as long as a certain condition

play12:15

is true in this case we have a variable

play12:17

called number set to three

play12:18

and we're saying while the number does

play12:20

not equal zero

play12:21

execute the code inside the loop in this

play12:23

case we'll just print the number

play12:25

and decrement it then when we get to

play12:27

zero we'll print the next line which is

play12:29

left off if we run the program it will

play12:31

print three two one

play12:32

left off the last type of loop is a for

play12:35

loop or a four

play12:36

in loop and this is useful when you're

play12:38

looping through a

play12:39

collection so here we have a collection

play12:41

of integers and we want to loop through

play12:42

it to do that we'll type in 4

play12:45

element in and then our variable name

play12:47

which is a

play12:48

dot which will give us an iterator for

play12:51

the array

play12:52

and then curly brackets finally we'll

play12:54

print the element

play12:55

this is saying for every element in our

play12:58

array take that element and print it to

play13:00

the screen we can also use the for loop

play13:01

to loop over our range which is a type

play13:03

provided by the standard library

play13:05

which represents a sequence of numbers

play13:07

as an example we could type in 4

play13:09

number in and this time we'll do

play13:12

parentheses

play13:13

1 dot 4 curly brackets

play13:17

and we'll print the number and

play13:19

apparently the parentheses are not

play13:21

required so we can remove those

play13:25

okay so this is a range and what it will

play13:27

do is create a sequence of numbers from

play13:29

1

play13:30

to 3 because the last number is

play13:32

exclusive running the for loop on it

play13:34

will do the same thing as before

play13:35

we'll say for every number in this range

play13:38

take the number

play13:38

and print it out we can go ahead and run

play13:40

our program and as you can see we get

play13:42

the values in our

play13:43

array and then we get the values in our

play13:45

range and really quickly i just want to

play13:47

go over comments

play13:48

we have two basic types of comments in

play13:50

rust there are single line comments

play13:51

which you can write using two forward

play13:53

slashes

play13:53

and there are block comments which you

play13:55

can write using a forward slash an

play13:56

asterisk

play13:57

and to end it an asterisk and a forward

play13:59

slash there are also document comments

play14:02

but we'll learn about that

play14:03

at another time and there you have it

play14:05

chapter 3 complete

play14:06

we learned about variables basic types

play14:08

functions

play14:09

comments and control flow if you like

play14:11

this video make sure to give it a like

play14:13

and if you want more rust content make

play14:15

sure to subscribe

play14:16

and hit the notification bell to be

play14:18

notified when new videos

play14:19

come out i'll see you in the next one

Rate This

5.0 / 5 (0 votes)

Related Tags
Rustプログラミングプログラミング入門変数不変性データ型関数定義制御構造コメントチュートリアルプログラミング言語開発者向け教育
Do you need a summary in English?