►
Description
This video was recorded during the Rust KW Meetup in Kitchener-Waterloo, ON, Canada on March 5, 2019.
https://www.meetup.com/Rust-KW/events/259334630/
In this talk, I will walk you through the debugging of a problem I had in one of my early Rust projects: An emulator of the classic console Space Invaders. The problem, related to the borrow checker, is a great example for beginners with experience in other languages. You'll get to learn how the borrow checker works and idioms for common operations.
Talk written and presented by: Agustín Chiappe Berrini (https://github.com/AgustinCB)
Recording: Mark Sherry
A
A
It
was
my
first
project
and
I
wanted
to
learn
a
little
bit
housework.
It
was
an
interesting
problem
that
helped
me
understand
how
the
protocol
works
and
I
think
that
it's
a
great
example
for
someone
who's
just
starting
on
the
language
and
it's
familiar
with
other
for
programming
languages,
but
not
particularly
with
oddities
of
rust.
It's
also
a
good
example,
because
I
eat
a
lot
of
stupid
stuff
that
I
could
have
a
pardon
prevented
of
like
actually
reading
the
recommendation.
A
A
It's
the
whole
soul.
It's
made
out
of
the
cpu
intel
8080,
which
was
one
of
the
first
bits
abused
and
a
bunch
of
external
harbor
at
the
time,
the
shared
memory.
So
you
will
say
it's
what
it
was
called
memory
mapping
and
you
will
say
well
from
this
address
to
the
suburbs.
The
those
bytes
are
allowed
to
be
write
and
read
by
external
parties
there.
A
It
is,
if
you
work
in
a
different
way,
so
to
communicate
with
devices,
you
will
use
what
was
called
IO
pins
that
were
input/output
pins,
to
which
you
will
connect
your
devices,
the
elbows.
Now
the
CPU
has
two
instructions,
one
it's
called
in
and
what
an
element
it's
gone
up
its
instruction
as
an
argument.
So
with
the
instruction
you
store
the
content
of
the
beam
ID
of
that
argument
into
the
accumulator
and
with
our
construction,
you
start
the
emulator
into
the
device
externalize,
whose
idea
is
there?
A
The
problem
that
I
encountered
was
were
trying
to
design
this
particle.
The
problem
was
because
they
tried
to
do
something
that
was
as
expensive
as
possible.
My
idea
was
well.
I
would
first
create
this
console
and
then
I
will
modify
it
slightly
to
make
some
kind
of
fantasy
console
based
on
the
banners.
A
A
My
first
attempt
with
something
ladies
I
have
to
trade
for
input
and
output
devices,
and
these
are
two
examples
of
input
and
output
devices.
One
example
will
be
a
batter
the
control
had
in
particular
six
pathos.
Another
example
would
be
a
sunglass
in
this
case
the
console
had
an
external
camera
device
that
will
connect
to
six
different
things
and
everything
when
you
send
an
instruction
to
everything,
a
different
sound
will
be
reproduced.
A
B
A
Was
my
so
I
try
to
yeah
so,
but
it's
itself
here
is
that
the
trial
of
if
the
device
is
not
satisfied
and
it's
Remy
explaining
you
hear
that
this
is
actually
a
ready
disorder
to
a
sound
and
therefore
it'll
support.
If
you
go
and
read
the
documentation
and
you,
which
is
what
I
did
at
the
time,
you
will
notice
that
there
is
an
actual
structure
to
solve
this
problem,
which
is
the
reference
counter.
B
A
It's
basically
the
same
but
replacing
the
bob
says
within
the
sensations
of
the
person,
a
student
here
and
then
the
work
plan,
so
this
compatible
copy.
The
name
is
continence
problem.
The
next
problem
is
okay.
This
works
now,
but
this
is
not
exactly
what
they
need
when
you
input
something
in
the
balance,
I
need
to
be
able
to
store
that
I
press
that
button,
because
a
different
part
of
the
application.
A
We
have
to
be
able
to
read
the
list
of
photos
and
see
which
one
are
impressed
to
be
able
to
obtain
whether
it's
cash,
so
I
needed
to
do
some
kind
of
mutability.
On
this.
On
this
object,
my
partition
was
well
I'm
sure
that
RC
won't
complain
if
I
just
make
variable
and
like
in
here
I
try
to
use
that
that
will
fail.
B
A
Yeah
so
again,
I
learned
this
way
that
the
earthly
structure
is
actually
mutable
and
that
it
requires
you
to
not
change.
The
data
really
frustrated.
I
went
back
to
the
book
and
I
started
reading
again
in
the
same
chapter,
and
they
found
another
in
suture
another
instruction
that
was
basically
in
the
same
page
called
Russia.
It
was
basically
well.
This
is
the
solution.
What
you
need,
mutable
data
amazing
I,
will
just
replace
all
their
see.
We
Russell
because
he
didn't
continue.
Reading
I,
just
I.
A
So
what
is
saying
here?
What
is
in
here
is
that
grabs
and
requires
the
argument
took
her
sass.
The
problem
is
because,
in
this
case,
what
they
had
was
a
rough
salad
of
traits
and
the
compiler
didn't
know
the
size
of
the
trait
I
wasn't
able
to
use
it.
What
I
went
back
to
the
book
and
then
try
to
interpret
I
said
well?
A
A
The
compiler
scream
at
me
again
and
say:
well,
you
can't
turn
this
do
what
we
do,
because
if
you
remember
before
the
objects
that
I
have
ownership
in
my
stability,
I
thought
that
perhaps
I'll
work.
Similarly
to
the
reference
counter
in
the
sense
that
it
will
allow
multiple
owners,
they
thought
that
it
was
the
reference
container
rather,
but
with
mutability
enabled
it
was
not.
Obviously
so
I
went
back
to
the
book.
I
kept
reading
and
I
found.
The
solution,
which
is
this
it's
horrible
I
was
I,
was.
A
A
There
was
already
trading
which
they
basically
pose,
the
same
question
to
me
and
what
they
basically
see
say
here
is
well
you're
right
that
is
forward,
but
you
don't
actually
need
to
put
the
shunt
information
on
ecologic.
It's
very
likely
that
the
part
that
is
shared,
it's
not
the
core
object,
but
a
particular
manner.
So
what
you
can
do
is
just
make
your
vector
a
vector
of
reference
content,
trades
and
the
actual
implementations
have
their
members
that
are
actually
shared,
rot
in
red
cells
and
all
of
these
songs,
overly
complicated,
so
show
me
the
cover.
A
A
Here
the
CPU
this
factory,
instead
of
being
that
monstrosity
is
just
a
vector
of
reference
content
versions
of
that,
because
reference
count
don't
need
doesn't
need
the
box.
This
is
actually
a
new
addition.
It
keeps
being
very
conscious
and
the
implementation
here,
it's
a
sofa,
Lister
power
users,
any
said
whatever
you
need,
you
can.
A
A
Next,
we'll
move
my
complexity
down
the
abstraction
abstraction
here.
I,
don't
want
all
my
rappers
and
all
that
complexity
on
the
first
level
of
the
year.
I
want
it
short
in
the
place
is
muting
it.
It's
unfortunate
that
I
told
Calvinistic
way
to
commit
around
the
obstruction,
but
I
will
also
leave
that
it's
a
good
engineering
practice
is
to
not
do
what
I
was
trying
to
do.