►
From YouTube: Rust Linz, June 2021 - Tim McNamara - How to learn Rust
Description
Rust is a complicated programming language with a helpful, yet pedantic compiler. This talk aims to provide you some strategies for learning Rust your next programming language.
In this session, you will deepen your understanding of some fundamental Rust concepts, learn to deconstruct its syntax into simpler pieces, and discover many tools available to you to help you learn.
Rust Linz at https://rust-linz.at
Twitter: https://twitter.com/rustlinz
Tim McNamara: https://twitter.com/timClicks
Speak at Rust Linz: https://sessionize.com/rust-linz
A
And
welcome
to
learning
how
to
learn
rust.
I
I
decided
to
talk
about
this
from
the
point
of
view
of
a
an
individual
who
is
intimidated
by
this
language
that
they
keep
hearing
is
too
big
to
learn
and
is
difficult,
and
I
don't
think
that's.
That's
necessarily
true.
My
my
view
is
that
you
should
start
small
and
just
start
with
a
small
part
of
the
language
and
then
grow
that
over
time,
this
talk
will
be
a
demonstration
of
one
strategy
or
forward
for
doing
so.
A
So
that's,
basically
the
entire
time.
You
know
if
you're
only
here
for
two
two
minutes.
That
is,
that
is
the
main
message.
So
just
a
very
small
introduction
to
me:
I've
been
a
programmer
former,
but
for
about
15
years
now
my
academic
credentials
are
in
the
humanities,
though
I'm
not
a
computer
science
major
as
we've
spoken
about
with
I've
just
published
the
russell
action
book,
I'm
also
the
organizer
of
our
local
meetup
group,
west
wellington.
A
So
there's
some
a
little
bit
of
the
cover
so
about
this
talk.
It
aims
to
provide
you
confidence,
it's
it's!
It's
number.
One
aim
is
to
give
you
enough
confidence
to
read
the
rest
of
the
material.
A
I
can't
teach
you
all
of
rust
today,
unfortunately,
and
secondly,
to
provide
you,
though,
with
a
strategy
for
learning
for
some
small
core
of
rust
that
can
be
used
to
make
practical
projects,
and
then
you
can
expand
that
knowledge
as
you
gain
confidence,
so
the
structure
of
the
talk
will
be
quite
loose.
We
will
be
going
through
code
examples
and
then
I
will
add
some
personal
thoughts
and
just
a
very
small
warning.
A
Some
of
those
thoughts
will
probably
be
conf
will
probably
be
incorrect
and
and
and
maybe
even
controversial,
so
we'll
see
what
jt
thinks
of
some
of
the
things
that
I
had
to
say.
Okay,
so
just
my
belief
is
that
in
terms
of
rust
is
that
rust
is
centered
around
two
main
things.
One
is
this
notion
of
a
trait
and
the
other
one
is
safe
access
to
data.
A
So
if
you
can
understand
those
two
concepts,
I
think
you'll
understand
the
majority
of
rust,
and
so
I
would
focus
on
structs
vectors
or
sort
of
like
vectors
of
structs
iterations.
So
how
to
like
process
that
data
within
a
vector
result
an
option?
Those
types
are
how
we
express
error
or
missing
values
inside
of
rust
programming,
and
if
you
can
focus
on
that
core
of
the
language.
A
A
Okay,
so
let's
learn
rust
in
small
pieces.
That
means
working
with
examples
that
provide
immediate
feedback.
A
When
you
get
the
compiler
to
work,
you
get
this
kind
of
very
small
release
of
dopamine
and
that's
actually
very
positive
from
a
learning
point
of
view,
because
it
provides
you
with
some
encouragement
to
continue
and
as
you
expand,
so
as
you
as
the
compiler
works
for
you
and
it
compiles,
you
can
then
expand
and
and
and
and
move
forward.
So
the
first
question
is
like:
where
do
I
start
with
rust,
and
then
we've
got
halo
lintz,
that's
great,
so
we
can
print
to
the
screen.
A
A
And
now
we've
got
some
intuition
about
what
a
variable
looks
like
in
in
in
rust,
and
then
it's
like
okay.
So
how
do
I
create
my
own
type
and
that
we
create
a
struct
definition
with
with
a
name
in
there,
and
then
we
also
learn
about
as
we
go
through
a
syntax
for
defining
a
structure
where
we
have
this
kind
of
literal
syntax
within
curly
braces,
and
we
put
the
name
in
here
and
then
we
can
field
access.
A
We
can.
We
use,
use
the
dot
operator
to
access
a
field
which
relates
to
this
string
over
here,
and
this
all
seems
like
it
will
work
and
then,
sadly,
it
will
not,
and
so
the
very
one
of
the
very
first
things
that
you
will
encounter
as
a
beginner
rust
programmer
is
this
distinction
between
a
string
and
ampersand
stir.
Luckily,
russ
actually
provides
a
helper
method
or
sorry
like
some
help,
along
with
its
compile
area.
Well,
why
don't
you
try
using
two
string
and
right
now,
as
a
beginner
rust
programmer?
A
But
what
I
want
you
to
remember
is
that
even
these
very
simple
examples
require
provide
like
there
is
actually
quite
a
lot
of
complexity
in
going
on
here
with
types
and
with
new
syntax,
and
if
you
have
not
programmed
before,
if
rust
is
your
first
programming
language,
it's
okay
to
go
slow,
we
will
actually
describe
so
so
we
we
apply
this
method
and
then
we
get
the
correct
or
the
desired
output.
Now
our
the
next
question
is
okay.
So
what
is
the
difference
between
a
string
and
an
ampersand
stir?
A
So
ampersand
stir
is
actually
normally
pronounced
as
a
string
slice,
and
we
will
understand
the
reasons
as
we
or
understand
that
distinction
as
we
as
we
develop
our
understanding,
but
remember
what
I
said
about
right
now:
we're
just
learning
the
core
and
we
will
expand
our
knowledge
over
time.
So
the
first.
The
next
thing
that
I
want
to
know
is
this
syntax
here
seems
kind
of
ugly.
A
I
would
like
to
understand
what
constructors
are,
and
so
I
I
introduce
I
kind
of
do
some
reading
and
I
find
discover
this
impul
block
and
I
can
add
my
own
methods.
In
fact,
in
this
case,
it's
a
it's
a
static
map
method
where
I
take
an
ampersand
stir
and
then
I
call
two
string
inside
new
and
get
the
same
result,
which
is
hello,
lins
and
we're
growing
our
language
over
time
with
small
examples.
A
A
So
the
first
thing
to
note
is
we
have
changed
the
type
that
our
name
is
accepting
from
a
specific
type
to
a
generic
type,
and
we
are
asking
rust
to
provide
to
accept
any
type
t
that
can
be
represented
as
a
stir
like
as
a
string
slice.
A
Actually,
it's
not
not
capitalists
like
a
little
little
s,
str
via
an
as
ref
method,
which
sounds
a
bit
strange
at
first.
But
what
this
means
is
that
we
can
take
a
reference
to
our
object
name
and
that
will
be
represented
as
a
string
slice
and
then
because
we
know
at
this
point
here
that
we
have
a
string,
slice
string,
size
methods
do
have
a
two-string
method
and
which
we've
already
used
twice
before,
and
so
that
can
allow
us
to
accept
either
either
argument.
A
This
is
an
unsatisfactory
way
to
get
what
to
achieve
the
outcome
that
we
that
we
want
we
incur
and
we
another.
We
incur
another
allocation,
a
memory
allocation
here
and
my
argument
will
be
that
when
you're
learning
the
extra
20
nanoseconds
that
you
will
incur
via
that
memory
allocation
is
an
acceptable
loss.
A
Okay,
and
so
we
so
we're
continuing
to
expand
our
example.
And
what
we
want
to
now
do
is
replace
this
print
line
statement
here.
Well,
I
don't
want
to
reveal
the
internals
of
name.
I
just
want
to
be
able
to
print
a
greeting.
A
So
how
do
I
ask
it
to
print
itself
and
it
turns
out
that
I've
got?
This
is
what
we
had
before,
and
this
here
is
new,
so
I
can
implement
or
bring
in.
I
learn
a
little
bit
about
bringing
in
other
libraries
and
I
can
implement
a
trait
display
or
format
display
for
greeting
my
custom
type
and
then
all
I
I
say
all
I
need
to
do
and
then
I
can
copy
the
example.
A
It's
able
to
be
accepted
by
the
print
by
the
by
this
kind
of
special
syntax.
With
inside
with
inside
the
print
line
macro,
okay,
cool
we've,
we've
gone
through
a
little
bit
of
the
strategy
of
how
to
grow
the
language
over
time.
You
want
to
use
small
examples
and
and
grow
them,
so
I
but
I,
but
I
do
want
to
give
you
permission
to
a
bit
confused,
because
rust
can
be
confusing.
A
For
example,
this
is
the
implementation
taken
directly
from
the
well
actually,
I've
added
some
syntax
I've
added
some
spacing
because
it's
so
small
for
the
standard
memory
drop
method.
Oh
sorry
function
now,
unlike
our
custom
type
before
so,
we'll
start
here,
we'll
start
with
the
t
it
accepts
every
type.
A
Now,
interestingly,
we
have
a
an
underscore
or
a
prefix
for
our
variable
x
and
that
prefix
of
the
underscore
provides
an
indication
to
you.
It's
like
a
convention
within
the
rust
community
that
we
don't
actually
make
use
of
that
argument,
and
then
it
turns
out,
though,
that
to
understand
what
this
function
is
doing.
A
You
need
to
understand
how
rust
rust
ownership
system,
and
so
what
this
syntax
here
does
we
take
the
underscore
x
by
value,
and
that
puts
the
s
that
moves
ownership
of
underscore
t
into
the
drop
scope
and
when
drop
scope
become
when
this
drops,
when
the
scope
ends
underscore
t
will
be
freed
up
or
deleted.
A
Now,
if
you
don't
know
enough
about
rust,
it
can
be
very,
very
confusing
and
a
good
sign
that
you
are
learning
rust
is
being
able
to
understand
the
drop
function
like
if
you
cannot,
if
you,
if
you
have
an
intuitive
understanding
of
what
is
happening
here.
That
means
it's
very
likely
that
you
are.
You
are
learning
rust,
another
one
that
confused
me
was
the
what
the
so-called
entry
api.
A
So
this
is
a
if
we
a
hash
map,
so
this
might
be
a
javascript
object
or
a
python
dictionary,
I'm
just
introducing
a
little
bit
of
more
some,
more
syntax
so
for
every
character
in
this
string.
Slice
vi
would
so
I
can
return
an
iterator
of
of
the
string
size
character
by
character.
A
I
want
to
add
in
the
character,
so
I've
got
this
entry
method
in
letters
and,
if
either
insert
oh
sorry,
either
retrieve
the
the
count
that
already
exists,
if
it
or
otherwise
start
with
zero,
and
then
this
syntax
here
with
the
star,
will
really
confuse
me,
because
when
I
started
with
rust,
I
had
only
used
python
and
I
didn't
really
understand
pointers.
A
This
counter
is
a
mutable
reference
to
what
is
inside
the
value
inside
this,
this
hash
map,
and
so
we
can
ask
rast
with
the
d
reference
operator,
which
happens
to
be
a
star,
that
it
should
increment
that
number
and
again.
This
is
another
case
where,
if
it
probably
looks
intimidating
and
strange
at
first,
but
if
you
are
learning
it,
if
you,
if
you
find
yourself
understanding
what
is
happening
here,
it's
a
good
sign
that
you
are
learning
rust
and
it's
that's
to
be
congratulated
and
the
other
one
I
think,
is
well.
A
The
the
other
is
another
example
from
the
standard
library
of
something
that
I
originally
found.
Very
very
strange
with
all
of
this
was
was
the
implementation
of
the
of
a
conversion
of
the
of
like
this
conversion,
trait
from
oh
sorry,
oh
actually
we're
implementing
into
on
the
basis
of
from
and
saying
for
every
type
t.
A
So
we're
actually
talking
only
about
t
and
we
can
convert
it
into
type.
U
so
for
every
type
t,
if
u
implements
from
of
t,
then
t
into?
U
also
works
and
it's
defined
by
its
inverse,
and
so,
if
you
are
becoming,
this
is
another
sign
where
it's
okay
to
be
confused
at
the
at
the
start
and
as
you,
your
rust
knowledge
is
growing
grows.
A
Then
then
syntax
like
this
will
start
to
be
less
unclear,
at
least
and
hopefully
over
time,
actually
understandable,
right.
Okay,
as
you
learn
rust,
there
will
be
parts
of
the
parts
of
your
learning
journey.
That
will
be
difficult,
and
so
my
view
is
that
you
should
try
to
be
realistic
with
the
amount
of
learning
that
the
the
amount
of
new
new
things
that
you
can
learn
at
any
one
time.
It's
okay,
to
sit
to
like
walk
your
own
path.
It's
okay
to
go
slow
rust
is
different.
It's
ownish
it.
A
A
A
And
I
don't
think
that
that
motivation
or
being
scared-
or
you
know,
worried
about
missing
out,
is
a
an
effective
way
or
is
likely
to
be
an
effective
way
for
you
to
learn
over
time
and
so
potentially.
I
would
encourage
you
to
switch
that
to
like
what
are
what
are
some
things
that
the
rust
language
can
offer
me
that
that
other
languages
cannot
and
the
emphasis
on
safe
access
to
memory
is
and
hi
is
very
valuable.
A
Whichever
language
that
you're
using
now
deliberate
practice
is
the
most
effective
way
to
learn,
and
that
means
that
setting
aside
time
and
being
deliberate
is
is
really
important.
Your
local
rust
community,
rust
lens,
for
example,
for
those
in
austria,
seems
to
be
doing
a
fantastic
job,
and
I
recommend
joining
the
discord
servers
either,
particularly
smaller
servers
as
well
or
finding
a
group
online
that
you
can
connect
to
and
ask
questions
with.
A
A
Now
just
kind
of
some
more
slightly
philosophical
parts,
so
I
think
that
you
should
give
yourself
permission
to
fail.
A
A
As
it
happens,
everyone
almost
everyone
feels
this
experience
that
everybody
else
in
the
room
is
more
qualified
than
they
are,
and
so
as
much
as
you
can
try
to
give
yourself
try
to
forgive
yourself.
If
you
encounter
this
this
kind
of
phenomenon
inside
your
brain,
your
brain
is
lying
to
you.
You
are
welcome
here.
The
rust
community
is
your
place
too.
You
have
a
seat
at
the
table
and
yeah.
Your
brain
is
lying
to
you.
A
A
If
the
borrowing
checker
is,
if
you
don't,
if
the
borrow
checker
is
difficult
or
you
don't
understand
why
the
compiler
is
complaining
to
you,
then
it's
okay
to
give
yourself
some
more
time
to
learn
and
the
other
one-
and
this
is
like,
I
think,
quite
important,
but
if
you're
from
c,
sharp
or
java,
it's
very
easy
to
write.
A
People
might
laugh
at
you
for
writing
java
or
c
sharp
in
rust,
and
I
want
you
to
know
that
I'm
just
going
to
get
all
of
these
through
that
it's
okay
to
write
java
in
rust.
While
you
are
learning
rust,
there
is
plenty
of
time
to
learn.
Idiomatic,
so
idiomatic
rust
is,
is
very
functional
in
its
approach.
It
like
prefers
high
order
programming
and
it
prefers.
A
I
find
really
really
elegant
abstraction
and
if
you
are
the
kind
of
person
who
likes
to
create
a
an
index
variable,
I
that
starts
at
zero
and
then
increment
that
that
very
that
index
over
time
then
start
there.
Because
I
guarantee
you
that
in
three
months
time
that
will
change
but
right
now,
what's
important
is:
is
your
own
learning
journey?
A
Don't
learn
more
than
the
minimum
required
for
the
next
step
and
and
right
and
one
one
thing
just
just
very
that
I'd
like
to
point
out
is
that
only
a
minority
of
rust's
programming
community
speaks
english
as
a
first
language
and.
A
Rust
uses
terminology,
that's
very
confusing,
and
isn't
you
would
not,
for
example,
borrowing
doesn't
not
involve.
It
doesn't
relate
very
well
to
the
concept
of
say,
borrowing
someone's
like
borrowing
someone's
screwdriver
or
like
hammer,
because
it
turns
out
that
you
can
have
multiple
borrows
like
read-only
access
to
to
data
type,
and
that
is
something
that,
where
there's
a
mismatch
between
the
analogy
and
the
rust
compiler,
likewise,
ownership
means
and
ownership
and
rust
means
something.
That's
very
different
than
ownership
in
terms
of
property
rights.
A
Property
rights
mean
that
you
have
the
power
to
exclude
everybody
else
from
your
property,
but
in
rust,
ownership
is
related
specifically
to
having
the
responsibility
of
destroying
their
value
when
drop
was
implemented
with
just
an
empty
block,
drop
had
to
respond,
drop
head
ownership
of
their
value,
and
that's
what
enabled
indicated
to
the
compiler
that,
when
drop
scope
finished,
it
should
be
freed
up
lifetimes,
are
another
sort
of
slightly
strange
concept.
A
The
in
our
our
plain,
english
or
you
know,
the
dictionary
definition
does
not
stretch
very
far
into
a
new
programming
language
and
even
things
like
references
and
smart
pointers.
All
of
this
jargon
can
be
confusing
and
so
again
give
yourself
permission
to
go
slow.
There
is
plenty
of
time
in
the
future.
A
A
There
are
some
very,
very
good
rust
code
around
and
trying
to
develop
an
intuition
for
what's
actually
happening
here.
So
in
this
case
we
are
connecting
to
a
web
server,
we're
creating
an
http
1.0
request
and
the
and
copying
the
output
directly
to
standard
out,
and
the
other
thing
to
note
is
that
there
are
there's
more
than
one
way
to
achieve
a
particular
outcome
in
this
case.
A
We're
looking
for
this
octal
value
of
204,
which
happens
to
be
132
in
decimal,
and
we
could
look
through
it
by
incrementing
through
the
haystack
and
then,
if
the
and
we
receive
a
reference
to
item
here
and
then,
if
it
matches
our
needle
then
which
is
132
well,
then
we
print
it
out.
Otherwise,
we
could
do
something
slightly
different,
which
is
use.
A
The
contains
method
either
way
is
fine,
especially
while
you're
learning,
because
what's
important
is
that
you
get
the
compiler
to
accept
your
code
right
now,
and
actually
I
just
want
to
say
that
even
with
a
very
small
amount
of
rust
you
can,
you
can
do
some
things
that
are
quite
interesting.
A
So
we
talked
about
structures
and
and
iterators.
So
we've
got
this.
We've
got
some
a
text.
Well,
we've
got
a
string
slice
of
new
zealand
penguin
data,
so
these
are
three
species
of
penguin.
The
little
penguin
actually
is.
A
You
know
nests
about
15
kilometers
away
from
where
I
am
now,
and
we
take
every
line
we
iterate
through
those
records,
and
so
this
is
a
csv
and
just
take
a
note
of
the
things
that
you
don't
yet
understand.
So
here's
some
new
syntax
we've
got
a
vector
and
we
use
are
using
an
underscore
as
a
placeholder
and
we're
splitting
on
on
commas.
So
that's
these
points
here.
A
So
we
now
have
two.
We
now
have
tuples
and
then
we
trim
all
white
space
and
then
collect
a
collector's
doing
something
magical
by
taking
all
of
our
iterators
and
collecting
them
into
one
vector.
One
thing
to
note
as
well
is
this
pause
method.
A
I
used
to
find
this
very,
very
magical,
but
it
turns
out
that
we
give
a
little
bit
of
a
we
give
a
type
hint
to
rust
and
it
is
actually
able
to
inspect
the
string
and
say:
okay,
I
know
that
you
want
a
floating
point
number
from
let's
say
65.
A
If
you,
if
you
slowly
sorry,
not
slowly,
if
you
build
up
from
small
examples
and
decide
that
if
you
build
up
from
small
examples,
you'll
be
able
to
take
on
more
and
more
complex
programs
quite
quickly,
I
find
okay
again
smartphone
go
gradually.
A
I
also
just
would
also
include
resultant
option
in
there
as
well,
and
everything
else
can
wait
or
come
next,
and
thank
you
very
much
for
listening.
I'm
happy
to
answer
any.