►
From YouTube: Default Methods in Rust
Description
Michael Sullivan, "Default Methods in Rust"
Help us caption & translate this video!
http://amara.org/v/2FhU/
A
A
Okay,
hey
I
am
Michael
Sullivan
I
am
a
PhD
student
at
Carnegie,
Mellon,
University
and
a
repeat
offender
intern
at
Mozilla.
This
is
my
fourth
summer
here
in
my
third
summer.
The
rust
program
in
mileage
project
and
this
summer,
I
mostly
worked
on
default
methods
in
rust.
Okay,
so
I'm
gonna
talk
a
bit
about
rust,
I'm,
going
to
talk
about
what
was
up
with
default
methods
and
then
some
other
stuff
things
I've
worked
on
the
summer.
Okay,
so
disclaimer
rust
is
still
under
heavy
development.
A
The
things
describing
this
talk
may
not
be
so
tomorrow,
although
at
this
point
they
mostly
are
what
I
discuss
and
how
I
present
issues
reflect
my
personal,
biases
and
language
design,
of
which
I
have
many
and
are
not
always
the
same
as
the
rest
of
the
Russ
team,
okay,
so
sort
of
fun
things.
What
do
we
want
out
of
a
programming
language
and
I?
Say
we
I
mean
Mozilla,
I,
guess
the
sort
of
people
who
might
want
to
write
a
web
browser?
Okay,
so
we
want
it
to
be
fast
right.
A
We
want
it
to
generate
the
fish
and
machine
code.
I
want
it
to
be
safe.
We
want
type
system
to
rule
out
certain
bugs,
so
we
can
more
easily
write
robust
software
and
we
want
it
to
be
a
concurrent
so
that
it's
easy
to
build
concurrent
programs
and
take
advantage
of
parallelism
right,
and
if
this
was
sort
of
a
architecture
talk
I
display
the
graph
of
Moore's
Law
leveling
out.
That's
the
start
of
every
talk
about
parallelism,
but
I'm
not
going
to
and
we
sort
of
wanted
to
be
systemc.
We
right.
A
We
we
want
it
to
have
fine-grained
control
over
when
we're
allocating
memory
and
when
we're
doing
expensive
things
and
want
to
be
able
to
reason
about
the
performance
of
it.
We
don't
want
there
to
be
too
much
magic
going
on
okay.
So
what
languages
do
we
have
sort
of
in
the
world
right?
Okay,
so
Firefox
is
written
in
C++,
which
is
certainly
fast,
and
it's
certainly
System
z,
but
it's
tough
to
write,
correct
concurrent
code
in
it
and
it's
definitely
not
safe
ml.
Like
standard
ml.
A
No
camel
is,
you
know,
usually
sat
safe,
usually
fast,
and
it's
very
safe.
It's
you
know,
got
very
expressive
type
systems.
Erlang
is
safe
and
it's
concurrent,
but
it's
certainly
not
fast,
but
certainly
not
system.
Z
Haskell,
you
know,
can
be
fast,
it's
safe,
it
can
be
concurrent,
Java
and
c-sharp
are
both
fast
and
safe,
but
not
great
at
writing,
concurrent
code
or
system
Z
code.
A
So
what
we
want
is
rust
right,
a
systems
language
pursuing
the
trifecta,
safe
concurrent,
fast,
okay,
so
some
things
that
we
have
in
rust
is
we
have
algebraic
data
types
and
pattern
matching,
so
we
don't
have
any
null
pointers
and
it
makes
it
very
easy
to
sort
of
represent
things
like
in
the
compiler.
At
least
it's
nice
because
we
can
easily
represent
stuff
like
syntax,
trees
and
lists
are
very
easy
to
work
with,
and
you
know
optional
data
we
want
polymorphism
so
that
functions
and
types
can
have
type
parameters.
A
You
can
easily
write
a
function
that
you
know
operates
over
a
list
of
any
sort
of
we
want
type
inference,
so
we
don't
always
need
to
write
down
the
types
of
something
we
have.
A
somewhat
idiosyncratic
type
class
system
called
traits
that
we'll
talk
about
a
bit.
It
is
immutable
by
default
and
we
have
a
notion
of
légion
pointers
that
allow
safe
pointers
into
objects,
some
other
things.
We
have
lightweight
tasks
that
don't
share
state
with
each
other.
That
makes
it
very
easy
to
split
off.
A
Now
it's
written
in
rust
as
well.
It
uses
LPNs
back-end,
so
I
guess
want
to
say
the
compiler
is
written
in
rust,
really
I
guess
most
of
the
compilers
LLVM
like
LLVM
is
a
lot
bigger
than
rusty,
but
all
the
parts
that
know
about
roster,
room
and
rust
and
it
handles
polymorphism
and
type
classes
by
a
lot
of
morphozine
code,
which
means
it
generates
different
copies.
A
If
you,
if
you
have
a
you,
know,
function
to
reverse
a
list
of
any
sort
of
type
it'll
generate
a
different
copy
of
that
for
each
type
use
of
that
which
is
a
lot,
which
is
a
lot
like
how
C++
templates
work.
Okay,
so
the
catch,
though,
is
that
you
know
we're
not
quite
ready
for
primetime,
yet
there's
still
lots
of
bugs
and
exposed
sharp
edges.
A
Language
is
still
evolving,
but
we're
getting
really
close,
although
I
did
used
this
slide
last
summer
to
what
haven't
we
close
with
a
summer
that
ok,
so
what
I
worked
on
was
the
the
trait
system,
so
traits
are
interfaces
that
specify
a
set
of
methods
for
a
typed
implement
and
then
functions
can
be
parameterized
over
types
that
implement
a
trait.
This
is
just
like
Haskell
type
classes,
and
a
chair
is
more
than
a
passing
similarity
with
Java
interfaces.
So
an
example
of
this
is,
let's
say
we
have.
A
We
can
define
the
trait
of
things
that
we
can
format
as
a
string
right.
We
have
a
trait
to
stir
and
it
has
one
function
called
to
stir
it.
You
know,
takes
an
object
and
turns
it
into
a
string,
and
so
we
can
then
go
implement
this
for
integers
and
I
mean
we
just
call
akin
to
star,
but
so
then
the
one
way
you
can
use
this.
A
As
you
can
write,
you
know
a
function
called
exclaim
that
for
any
sort
of
object
that
you
can
format
as
a
string
returns
that
object
but
more
excited
right,
so
it
it
takes
in
some
X
that
is
of
type
T
that
implements
to
stir
format.
This
is
a
string
and
it
adds
an
exclamation
mark
at
the
end.
Okay,
that's
not
that
compelling
of
an
example
but
and
then
we
can
also
implement
traits.
A
We
can
create
trade
implementations
that
are
based
on
other
ones.
So
if
we
have
a
implementation
of
to
stir
for
some
type
T,
then
we
also
know
how
to
format
as
a
string
and
array
of
T
right.
We
just
map
over
all
the
elements
formatting
each
of
them
and
then
I
screwed
up
this
example.
It
needs
to
it's
supposed
to
be
calling
connect
down
the
string
to
put
commas
in
between,
but
but
so
you
can,
you
can
create
this
sort
of
build
up
implementations
of
traits
from
oh.
A
Okay,
so
then
it's
not
the
right
title
for
the
slide:
okay,
okay,
so
something
that's
useful
in
the
sort
of
traits
is
you
want
to
have
a
method
where
there's
sort
of
a
default
implementation
of
it?
But
you
still
want
to
be
able
to
provide
an
alternate
one.
So
an
example
of
this
is
you
want
to
trade
representing
equality
and
has
a
method
that
tests,
whether
two
elements
are
equal
and
one?
A
That's
handy,
you
can
also
choose
to
override
it
in
this
case,
if
you
want,
you
know,
sort
of
a
more
efficient
implementations
doing
this
would
probably
save
like
one
instruction
or
something
right
instead
of
doing
equality
in
negating
it,
you
just
do
in
equality,
it
actually
save
a
function.
Call
if
your
optimizer
is
bad,
so
double
DM
is
pretty
good,
so
actually
might
be
the
same.
A
Okay,
so
overwriting
can
be
useful
for
performance,
as
in
sort
of
that
example,
except
probably
not,
because
compilers
are
good
at
optimizing,
and
sometimes
it's
actually
semantically
necessary
right
like
for
floating-point
numbers.
It
is
not
actually
the
case
that
inequality
is
just
the
inverse
of
equality
right.
If
one
of
the
two
elements
is
not
a
number
than
both
equality
and
inequality
or
false.
A
Okay,
so
the
state
at
the
start
of
my
internship
was
all
of
those
above
examples
work.
The
code
I
showed,
but
basically
nothing
else
did.
Oh,
okay,
so
one
example
of
something
that
didn't
work
is,
if
you
had
any
type
parameters
on
the
trade,
oh
and
that
would
trigger
an
internal
compiler
error.
So
here
we
have
a
trait
that's
parameterised
over
some
type
T
and
it
the
function.
You
know
takes
the
argument,
its
invoked
on
and
something
of
type
T
and
just
returns
its
argument.
A
Here
we
have
an
implementation
of
it
for
int,
with
int
as
the
type
parameter
and
and
it
didn't
work,
and
the
reason
for
that
is
that
there
was
a
sort
of
mismatch
between
the
type
parameters
that
it
thought
were
on
the
function
it
was
calling
and
the
actual
type
parameters
used
in
the
implementation
of
the
trade
and
I'm
not
going
to
go
into
this
too
much
because
it's
sort
of
obnoxiously
technical.
But
this
sort
of
thing
was
the
main
problem.
A
I
worked
on
over
the
summer,
there's
just
a
lot
wrong
with
this
order,
dolphin
Emmas
or
surprisingly
subtle.
Another
thing
that
didn't
work
is
if
you
wanted
to
call
a
default
method
from
another
default
method
like
here.
We
have
a
cat,
trait
and
the
scratch
method
wants
to
call
it
her
method
and
it
would
crash
with
the
compiler
and
also
didn't
work
if
you
wanted
to
call
a
default
map
method
through
a
type
parameter
or
package
up
an
object
with
the
default
method,
and
so
originally
I
fixed.
A
Another
problem
is,
if
you
had
had
a
default
method
that
was
defined
in
a
trait
that
was
in
another
library.
You
couldn't
call
it
and
I
had
a
bunch
of
false
starts
here,
because
the
code
for
emitting
data
about
what
is
in
another
library
and
reading
it
in
is
really
scary
code.
It's
just
really
awful
stuff.
It's
sort
of
like
inherently
an
annoying
problem,
but
our
code
is
about
ten
times
worse
than
the
problem
is,
and
the
solution
is
to
sort
of
properly
actually
export.
The
information
instead
of.
A
But
that's
a
huge
pain
because
all
of
our
code
for
exporting
information
about
libraries
is
awful
and
it
also
required
a
pretty
big
rework
of
all
of
the
data
structures
involving
the
type
class
system
more
stuff
is
when
you
had
a
you,
had
a
trait
with
type
parameters
on
it.
It
didn't
work
I'm
not
going
to
go
into
too
much
problem.
That
means,
but
basically
anything
involving.
A
Then
there
were
also
a
ton
of
problems
with
the
interaction
threads
which
involved
the
most
yak
shaving
of
the
summer,
because
it
required
a
major
rework
of
how
super
trait
calls
are
handled,
which
meant
that
we
needed
to
actually
check
how
it
weather
implementations
actually
implemented.
All
the
super
traits
which
required
improving
the
trait
resolution
algorithm.
A
Yak
shaving
is
sort
of
the
basically
every
time
you
need
to
fix
anything
in
the
rust
compiler.
There
are
like
five
things
you
need
to
fix
first
and
it's
it's
sort
of
one
of
the
biggest
problems
working
on
it.
So
other
things
that
did
the
summarize
I
improved.
The
trait
resolution
algorithm,
like
I
just
mentioned,
which
allowed
us
to
fix
a
bunch
of
code
that
is
using
workarounds
I
fixed
some
bugs
and
pattern
matching
before.
A
I
think
I
hit
it
just
barely
this
summer,
I'm
well
sure
to
probably
have
like
0.6
bugs
closed
four
days
of
the
summer.
So,
in
conclusion,
rust
is
a
new
systems:
language
out
of
Mozilla
research.
That's
designed
to
be
a
fast
concurrent
and
safe
I
work
down
a
bunch
of
different
stuff
on
it.
The
summer
and
default
methods
work
now,
if
you're
less
programmer,
which
you
aren't.