►
From YouTube: RustLang Meetup Malaysia - July 2021
Description
Do join us at discord https://discord.gg/9Xj8H2EXTD
Rust malaysia meetup july 2021 discussing zero-cost abstractions, iterators and live coding.
A
About
I'll
be
talking
about
zero
cost
abstraction
in
rust
and
iterators
and
then
at
the
end
there
will
be
like
a
live
coding
session,
and
this
time
there
will
be
more
interactions
and.
B
Before
before
we
start,
I
would
like
to
introduce
the
speaker
for
today
we
have
ivan,
which
is
on
my
right
side
and
then
co-organizer
for
the
meetup.
So
if
you
are
interested
in
joining
us,
please
do
join
the
discord
discord
channel.
If
otherwise,
you
have
you,
you
are
free,
feel
free
to
leave
a
comment
on
youtube
streaming.
B
B
A
Are
you
ready?
Okay,
welcome,
welcome
to
rasmita
july
and
today
I'll
be
talking
about
zero
cost
abstraction
in
rust,
and
then
it
will
be
a
lot
of
the
most
of
the
parts
will
be
talking
about
iterators,
and
today
there
will
be
more.
You
know
more
discussion,
more
interactions,
so
y'all
may
need
to
ask
questions
in
in
the
in
the
group,
discord,
group
and
and
then
at
the
end
there
will
be
a
live
coding
session
and
just
wondering
have
you
ever
heard
of
zero
cost
extraction?
A
B
A
A
B
A
Can
you
see
the
slide
here
right
there,
all
right
got
it
yeah
and
then
this
is
the,
and
this
is
the
can
you
can
you
see
the
website
now
on
and
this
is
the
o1.
A
A
A
A
As
in
you,
don't
you
don't
just
interface
with
directly
interface
with
to
do
indexing,
changing
the
characters
on
on
original,
using
for
loop
everywhere
right
so
with
expressions.
You
can
write
something
like
high
level
high
level
you
can.
You
can
have
an
iterator,
which
is
high
level.
You
don't
need
to
write
every
time.
You
don't
need
to
do
like
a
for
loop
and
there's
like
classes
interfaces
trades
that
are
all
considered
abstractions
and,
for
example,
you
see
here
is
you
can
have
right?
C
A
A
A
A
As
in
like,
for
example,
you
write,
like
you,
write
some
iterators
in
other
language.
You
have
a
course
like
if
you
want
to
do
some
classes
or
something
in
most
languages
with
in
most
high-level
languages,
they
have
cost
like
using
using.
Sometimes
you
might
hear
using
for
loop
is
faster
than
using
while
loop,
so
using
follow
is
faster
than
using
the
iterator
api
and
or
something
like
that.
A
A
It
is
likely
that
the
for
loop
will
be
faster
than
the
iterator
and
there
will
be
like
the
iterator
will
be
a
bit.
It
will
be
slower
than
the
follow,
but
in
rush
right
the
iterator
will
be
faster
than
in
most
cases
it
will
be
faster
than
what
your
have
right
for
those
that
doesn't
know
is
iterator.
Iterator
is
just
a
synthetic
synthetic
trigger
for
like
wow,
I
iterator
next
and
then
do
something
with
it.
A
A
A
It
will
be
this.
You
see
this
will
be
similar
to
this.
It's
essentially
just
a
synthetic
sugar
to
use
the
iterator
and
c
dot.
Next
is
the
iterator
api.
Iterator
is
just
if
you
don't
know
what
iterator
iterator
is
like
an
expression
to
let
you
iterate
on
something
like
an
array
yeah,
that's
why
it's
an
iterator
and
then
expressions
about
zero
cost
like
how.
How
does
it
do
that?
Because
we
thought
like
how
come
how
come
like,
for
example,
you
see
in
this
comparison
right.
A
This
is
the
comparison
using
for
loop
and
this
comparison
using
your
iterator,
and
you
see
that
the
iterator
is
faster
than
the
for
loop,
like
how
so
the
thing
is
usually
in
iterator,
it
might
be
faster
than
what
you
can
right
in
for
loop.
If
it's
a
simple
one
and
even
a
complicated
one,
most
of
the
time
it
can
be
faster,
it
is
faster
than
the
for
loop
using
like
manually
unloop
it
you
see
something
like
this
iterator.
A
A
So
the
zero
cost
abstractions
essentially
means
that
the
runtime
cost
of
the
iterator
is
actually
being
a
compound
time
cost
in
which
that
the
the
component
is
slow
right.
So
it
means
that
it
is
compiled,
is
probably
one
the
reason.
One
of
the
reasons
why
a
couple
times
low
because
of
too
many
attractions
like
this
and
but
yeah
there's,
no,
that's
like
almost
no.
They
don't
cause
anything
during
runtime
like
the
types
will
optimize
out
into
like
without
without
types
and
the
enums
doesn't
cost
anything
even
in
runtime.
A
So
the
base
iterator
phase
looks
like
this.
Iterator
is
a
trade
a
trade
inside?
If
you
don't,
if
you
don't
know
us,
a
trade
is
something
that
defines
the
behavior
of
something
it's
a
bit
like
abstract
interface,
it's
sort
of
like
abstract
interface.
You
just
say
like
what
is
the
behavior
or
something
you
can?
You
can
add
methods
for
you
can
implement
a
trade
for
like
a
strut
or
an
enum.
A
This
something
like
this,
so
there
will
be
item
type
and
then
next,
if
you
call
the
function
next
right,
it
will
mutable
mutably,
take
itself
and
then
return
the
next
item
in
the
iterator.
So
basically
this
like
the
main
iterator.
Usually
if
you
you
just
you
just
do
this,
the
call,
usually
you
just
implement
this
and
it's
fine-
you
don't
need
to
implement
other
items
in
iterator
and
then
there
are
three
forms
of
iterator.
One
is
eater.
The
mute
and
intuitor
ether
is
just
iterate
over
a
reference
of
part.
A
A
Then
you
write,
you
implement
the
trade
iterator
for
counter.
So
what
this
does
is
the
counter
we
will
have.
We
will
will
contain
the
iterator
or
what
items
do
size,
which
is
like
the
counting
and
then
next.
Next
is
the
only
required
method
right,
so
you
can
only
just
implement
next
and
then
you
get
the
iterator.
A
So
you
can
just
self
count
your
increment
account
by
one
and
then,
if,
if
it's
less
than
six
you'll
return,
the
self
count
and
then
you'll
get
like
it's,
not
your
return,
none.
So
the
option
is
like
office.
Whether
something
is
there
or
not.
So
this
is
to
prevent,
if
you
don't
know
why
the
option
is
just
just
like
algebraic
data
type
that
lets
you
cover.
None,
for
example,
it
could
be,
it
could
be
something
or
it
could
be
none.
A
A
A
For
example,
map
is
just
created
from
map
the
map
method
and
then
some
of
these
some
of
these
structures
right,
have
implement
certain
trade.
Some
of
them
doesn't
implement
certain
trade,
so
it's
like
they
can
optimize
this
to
a
very,
very
to
a
very
deep
level.
They
can
optimize
it
and
there
are
a
few
of
the
trades
that
helps
in
improving
the
speed
of
the
iterator
and
to
identify
the
pattern
of
the
iterator
so
that
there
are
multiple
traits
in
iterator.
A
A
Then
there
are
x,
there's
exact
size,
iterator
exercise
iterator
is
like
you
know
the
you
know
the
size
of
the
iterator,
whether
it's
empty
or
or
you
get
the
length.
So
these
are
some
of
the
methods
that
let
like,
for
example,
there
are.
There
are
some
specializations
that
let's
say
if
they
have
this
kind
of
trade,
they'll
use
some
specialized
function
to
speed
it
up
and
then
there's
also
like
fused
iterator.
A
These
are
some
mechanism
like
once
the
iterator
is
fused,
it
will
stop
producing
value,
and
so
these
are
some
tricks,
for
example,
and
then
speeding
up
the
iterator
is
usually
done
by
using
the
iterator
size
in
right.
I
always
go
there
iterator,
okay,
let's
look
at
the
iterator
trade.
A
They
can
just
allocate
once
just
enough
capacity
for
the
whole
whole
thing,
which
is
why
these
are.
These
are
one
trick
they
do
and
then
there's
also
trusted
land
trusted
is
not
here.
I
don't
think
it's
here.
Oh
he's
here
so
translate
is
just
another
trade,
but
this
is
a
likely
trick.
So
this
lets
the
user
know
that
the
length
is
exciting
but
exact,
except
that
this
knows
that
users
know
that
you
have
exactly
like
that
size.
A
A
You
can,
you
can
directly
take
the
original
buffer
and
you
can
directly
modify
that
buffer
to
take
the
buffer
and
take
it
for
another
iterator
and
optimization
step,
but
this
is
not
not
a
good
for
everyone
to
use,
so
this
is
only
they
only
implement
this
for
the
internal
brass
iterable
structs,
but
most
of
the
time
you
don't
need
to
do
this.
Usually
it's
fast
enough.
A
If
you
just
use
the
center
iterator
yeah
and
something
new
since
rust,
right,
you
can
use
the
cons
generic
air
indexing,
like
you,
can
do
one
like
one,
two,
three
decent
array.
You
see
this.
This
is
an
array,
but
you
don't
need
to
do
this
either.
Last
time
you
need
to
do
one
dot,
eater
and
chain
two,
but
right
now
you
don't
need
to
do
this.
It's
a
lot
more!
A
A
A
A
C
A
A
A
Intuitor
into
eater
is
just
covered
forward
that
forward
the
original
thing
into
an
iterator
which
iterates
over
the
value,
rather
than
rather
than
the
reference
it
iterates
directly
over
the
original
value
and
collect,
is
just
collect
into
a
different
struct,
but
this
doesn't
work.
You
see.
A
A
A
A
C
A
A
A
A
A
I
can't
find
to
it
by
an
issue
I
can't
find
it
shouldn't
be
like
this,
but
now
mine
are
open.
True,
so,
okay,
you
look
into
this
right.
You
can
see
at
it
right
for
this
implemented,
not
for
what,
but
for
slice.
A
A
A
A
A
A
A
A
A
You
need
to
construct
it
by
using
the
original
value,
but
I
don't
know
I
don't
know
why
they
didn't
implement
from
iterator
the
if
the
reference
for
origination
I
didn't,
I
didn't
know
why
maybe
there's
a
reason,
but
I'm
not
sure
why
it's
the
reason
yeah.
I
don't
know
why
yeah
they
will
implement,
extend
with
reference.
A
A
A
A
A
A
A
A
A
A
A
A
You'll
go
through
four
item
eight
item
in
one
shot,
rather
than
going
through
one
by
one.
So
like
it's
like
it's
a
free
optimization,
but
sometimes
you
need
to
tweak
it
a
bit
the
iterator
to
eat
a
bit.
But
it's
not
always
it's
not
always,
okay,
so
only
sometimes
you
might
be
able
to
make
use
of
smd.
But
if
you,
if
it
makes
use
of
smd,
it
will
be
a
lot
faster.
A
Okay
and
then
this
is.
These
are
mostly
because,
due
to
the
types
in
place,
the
types
other
like,
for
example,
yeah
the
types
they
have
in
place
and
a
lot.
It
depends
a
lot
on
the
compiler.
But
if
you
still
want
to
manually
vectorize
manually
the
right
smd
code,
you
might
want
to
like
use
the
smd,
which
is
a
lot
harder
to
write.
A
A
Not
like
this
either,
maybe
this
is
a
very
high
level
one,
but
yeah
not
like
this.
Something
like
here's
an
example
srmd.
A
A
A
A
A
A
A
A
A
A
A
But
it's
not
oh,
it's
not
pyoxidizer,
but
yeah.
So
there
are
quite
a
lot
of
iterators
I'll.
Just
look
through
a
few
first
last
iterator
you
can
have.
You
can
have
all
of
these.
If
you
just
implement
the
next
method
in
iterator,
you
just
implement
this
one
required
method.
Then
you
get
all
of
this
for
free.
A
A
A
A
Step
by
side
just
keep
the
skip
certain
step,
no
step
by
you
go
through
like
every
nth
step,
like,
for
example,
you
have
to
step
by
two.
It
will
be
zero,
two
four,
it
will
go
two
step
and
then
max
is
just
get.
The
max
item
in
the
iterator
mean
get
the
minimum
item
in
the
iterator
zip.
You
can
zip
multiple
iterator
together,
you
can
zip
another
iterator,
so
you'll
get
two
items
in
one
shot,
so
that's
it
and
enumerate.
A
A
A
A
A
B
B
Before
that,
I
think
you
may
want
to
explain
why
an
array
is
not
an
iterator.
You
cannot.
You
cannot
do
a
enumerate
call
directly
on
the
array.
A
A
A
This
means
this
array,
but
it
doesn't
show
the
each
let's
show
the
length.
This
is
a
mutable
reference,
which
means
a
reference
and
mutable
yeah.
This
one
can
can
be
another
top,
but
it
just
it's
just
like
a
mutable,
it's
a
mutable
pointer,
but
it's
an
immutable
reference
to
an
array,
but
this
one
is
to
a
slide,
no,
this
to
a
slice,
but
this
is
to
an
array
of
three
items.
A
A
This
is
why
they
call
the
cons,
generic
things
considering
or
something
so
this
array,
if
the
number
is
here
yeah
they
added
this
quite
recent.
So
maybe
not.
Every
item
is
implemented,
which
is
why
you
get
this
error
yeah
and
then,
if
you
do,
it
means
that
it
will
directly
make
it
into
a
reference
which
will
work.
A
A
A
A
A
A
A
Okay,
convert
the
result
into
option
result
result
is
that
option,
but
you
have
okay
and
error
type,
but
I
won't
explain
a
lot
of
that
here,
except
is
that
option,
but
it's
an
option
and
okay
just
convert
up
the
result
of
ok
to
sum
sum
value
and
error
to
none.
I
basically
just
convert
this.
If
can,
if
it
can
pass
this
into
integer,
it
will
return
the
integer
if
it
cannot
pass
it
return.
A
None!
That's
how
you
see
one
and
five.
All
these
are
embedded
so
there's
filter
map.
It's
quite
useful
for
four
is
like
four
is
like
reduced,
but
it's
not
reduced
so
far
you
can.
You
can
give
the
first
value
then
it's
like,
except
for
you
have
an
accumulator
and
for
each
of
the
value
you
you
pass
through.
You
can
use
the
accumulator
and
do
something
with
the
value
in
this
case.
It's
doing
a
sum
here,
your
initial
value
of
0,
accumulator
and
occasionally
x.
A
A
A
It's
like
it's
at
four.
First,
I
think
radius
is
like
four
first,
the
first
value
as
the
accumulator
reduce
that's
the
difference
and
then
there's
peakable.
We
show
pickup,
but
just
now
is
to
pick
to
the
next
value.
Saturn
is
like.
Let's
say:
if
you
have
a
array
array
of
array,
you
see
two
array,
you
flatten
it
into
single
array:
flatten
you
have
inspect
and
by
ref
inspect.
Unless
you
let
let
you
do
something
that
you
can
print
print
the
value
for
debugging,
it's
very
useful
for
debugging,
like
inspect
the
radio.
A
A
And
then
there's
partition
windows.
These
are
very
both
high
level
function.
Partition
is
like
it
will
partition
that
you
split
and
iterator
into
two
place.
Two
partition
like
for
in
this
example
is
you
split,
a
single
iterator
into
an
odd,
and
even
I
think
this
is
very
rare,
even
in
other
languages.
I
see
this
very
rare,
but
sometimes
I
think
it's
quite
useful.
You
split
this
into
odd
and
even
split
into
two
groups,
and
then
you
have
windows.
A
I
think
e.
Isn't
here?
No,
why
isn't
here?
I
think,
maybe
slice
only
have
this.
You
have
windows
as
in
like
first
two
value.
If
your
windows
2
means
second
value,
two
value,
this
windows
and
you
have
chunks
chunks
is
like
if
you
two
means
two
value
and
two
value
yeah.
This
is
chunk
and
that's
chunk
exact.
A
So
you
see
that
there
are
a
lot
of
methods
on
the
iterator.
I
think
technically
just
now.
The
two
is
not
it's
not
iterated,
but
it's
similar
to
the
functions
provided
by
iterator
and
collect
we
mentioned
about
call
light
just
now.
The
mechanism
is
it
uses
from
iterator
and
into
iterator
to
collect
into
any
type
of
one.
A
That's
all
on
any.
Oh,
oh
and
it's
quite
common.
It's
just.
If
all
of
the
items
fulfill
the
requirement,
then
you'll
return.
True
yeah,
it's
just
like
that
and
if
n,
if
all
means,
if
one
of
them
is
false
right,
then
the
iterator
will
stop
and
it
will
directly
return
force
inside
a
short
circuit
and
there
are
any
return
force
same
for
any
enemies.
If
any
of
the
items
return
true,
then
you
return
true.
A
So
that's
all
any
questions
I
think
it's
quite
common
in
even
the
other
language
is
quite
common
for
all
in
any,
and
you
have
some
product
cycle
some
some.
You
know
you
just
your
summit
yeah.
Basically
just
some
literature
add
them
together
here.
This
is
the
sum
trade
also.
So
if
you
have
anything
that
implements
the
sum
trade,
you
can
add
them
together,
product
is
just
multiply
them
and
cycle.
Is
you
can
just
like
like
look
again
loop
again,
this
is
like
you
see.
A
So
there
are
quite
a
lot
of
functions
here
and
if
you
know
them,
then
you
can
keep
the
code
very
short
and
concise,
but
you
might
spend
some
time
reading
reading
through
them
understanding
like
what
do.
What
do
what
yeah
any
questions
on
this
thing
go
through
yeah
go
through
quite
a
few
of
them,
which
I
commonly
use.
I
think
I
just
got
a
lot.
I
use
a
lot
of
them
frequently
different
ones,
yeah,
it's
quite
it's
quite
common,
though
I
mentioned
at
least
I
use
them
quite
frequently.
A
A
A
And
yeah
you
see
that
it's
very
high
level.
You
get
all
this
certain
very
high
level,
but
all
this
in
run
time,
they
don't
cost
stuff
like
so
is
related
to
the
zero
cost.
Abstraction,
as
in
everything,
is
types
in
during
compile
time,
and
it
will
be
combined
into
the
so
the
runtime.
All
these
types
are
gone
in
run
time.
You,
you
don't
get
the
types
unless,
unless
you
do
that,
unless
you
do
reflection
or
something
but
yeah,
you
don't
get
the
types
in
runtime.
A
That's
why
there's
no
cost
you
can
use
as
much
as
possible,
but
if
you
use
too
much
of
these
types,
sometimes
like
the
types
might
be
hard
to,
it
might
be
hard
to
debug
the
compiled
time
error.
The
types
are
like
so
long
and
you
don't
know
which
part
have
error,
but
if
you
are
used
to
it,
then
you
can
easily
pinpoint.
Where
is
the
error
during
compile
time
and
yeah
live
code.
A
A
A
Lazy
to
type
this
50
right,
so
what
this
does
is
you
generate
a
code
for
fibonacci,
which
is
zero,
zero
start
from
zero
in
payment
iterator
for
fibonacci
the
type
item?
You
know
you
see
iterator
right,
you
need
to
implement
the
type
and
item
and
you
need
to
implement
the
next
method,
which
takes
a
mutable
itself
to
return
option
of
the
cell
item.
A
A
Oh,
so
it
says
that
if
you
want
to
iterate
the
next
value,
because
the
next
right,
the
next
takes
a
mutable
self,
you
can't
just
next
without
being
mutable,
so
fibonacci
needs
to
be
mutable
as
in
it
needs
to
be
unique
and
other
other
items
can
change
it.
So
next
can
take
the
next.
I
can
change
the
next
value.
It
will
iterate
our
fibonacci
and
change
the
next
value.
A
A
A
A
Works
yeah.
A
Yeah,
because
this
is
because
this.
C
A
A
A
A
A
Yeah,
we
just
take
the
10
values
yeah.
So
just
take
one
one:
okay,
okay,
yeah
see
just
just
say
this
with
the
iterator
but
of
course
the
more
correct
version.
I
don't
think
my
motion
is
very
correct
here.
Supposedly
you
can
just
do
just
the
x
and
y
doesn't
make
sense.
Just
just
do
the
x
y
here
you
can
just
change
it
to
x
and.
C
A
C
C
C
A
A
Yeah,
so
is
there
any
question
on
this?
So
this
is
how
you
write
the
fibonacci
and
yeah.
Now
you
don't
need
multiple
here,
because
you
don't
run
the
next
value
just
to
enumerate
and
in
your
way
it
takes
self.
It
takes
the
original
original
structure,
the
whole
ownership
of
the
original
structure
and
then
enumerated.
That's
how
you
don't
need
the
build
and
yeah
this
output.
A
B
B
C
A
A
A
A
A
A
B
Of
the
day,
if
not,
we
are
closing
the
stream
soon
and
if
you
want
to
talk
to
ivan,
please
join
our
discord.
The
link
is
in
the
description
of
the
video.