►
From YouTube: Guillaume Gomez - Introducing gtk-rs
Description
Making the unsafe safe
The goal of this talk is to provide an introduction to the gtk bindings in Rust through the gtk-rs organization. It'll be mainly about how we made it and how we keep making it better.
Rust devroom @ FOSDEM 2018
https://fosdem.org/2018/schedule/event/rust_gtk_rs/
These talks have been recorded at FOSDEM (https://fosdem.org/)
This work is licensed under the Creative Commons Attribution 2.0 Belgium Licence.
To view a copy of this licence, visit http://creativecommons.org/licenses/by/2.0/be/deed.en
B
So
hi
I'm
here
to
present
you
a
GT
k
RS.
It
won't
be
a
technical
speak
at
all.
So
if
you
have
technical
questions,
we
can
speak
after
the
talk.
So
duty
cares
how
to
make
unsafely.
So
first,
what
is
duty
k?
So
it's
a
good
Nam
UI,
your
library,
where
we
were
used
in
the
UNIX
environments
so
cross-platform
it
works
as
well
on
the
Mac
and
as
far
as
I
know,
it
works
as
we're
on
Windows,
fine.
B
So
a
bit
of
history
at
first
it
was
started
by
a
very
merry,
are
Letang
in
2015
it
was
when
we
were
both
office
in
still
at
school.
We
started
it
to
learn
a
rest.
So
first
it
was
called
gtk
and
we
have
a
sub
crates
for
each
glom
library
like
a
Jo,
jellyband
stuff.
It
was
all
in
the
same
repository
at
the
opposite
of
currently
so
the
first
implementation
was
very
simple.
It
was
a
one
to
one
binding,
so
you
had
a
function
and
object.
B
It
was
the
same
interest,
so
not
much
of
entities,
but
you
could
use
the
gtk
interest.
So
now
the
comes
so
yeah.
It
was
at
the
time
very
slow
to
compile.
We
were
still
in
2015.
It
wasn't
that
we
had
a
huge
macro
to
generate.
Our
signals,
wasn't
very,
very
efficient,
so
so,
since
it
was
bound
by
him
a
lot
of
typos
human
errors
were
there
casting
errors.
B
Yeah
just
like
I
said
it
was
just
a
wrapper
around
the
C
code,
just
one
to
one,
not
much
safety
and
at
the
time
the
compiler
was
getting
updated
and
having
breaking
changes
like
every
two
or
three
days
or
so
changing
the
child.
Thousands
of
lines
at
once
was
quite
long
for
a
library
as
this
big,
so
that's
I
think
it
was
at
the
start
of
2016.
We
had
a
new
contributor.
We
brought
the
gear
support.
B
Some
gear
is
a
format
which
is
used
by
the
genome
libraries
to
describe
the
API
and
is
used
by
other
languages
to
generate
as
our
binding
and
that's
what
we
did:
investor
with
a
whole
new
create
gear
which
generates
all
the
code.
So
that's
the
first
thing
we
did.
We
also
reworked
all
the
GD
p--
how
to
explain.
The
g
lib
is
the
base
and
we
had
to
rewrite
it
in
order
to
make
it
work
to
build
upon
it.
That's
it
thought,
and
so
we
did,
that
we
have.
B
We
could
bring
a
whole
new
rating
system.
So
now
you
can
say
if
a
tray,
if
an
object,
inherits
from
another
very
helpful,
it
was
a
prevents
a
from
a
casting
from
a
type
to
another.
So
zit
and
another
thing
which
I
think
it's
still
a
bit
of
a
debate,
but
we
decided
to
split
libraries
into
is
their
own
repository.
So
now
Jacob
isn't
in
GT
Kelley
repository
anymore.
It's
the
same
organization,
but
not
the
same
repository,
which
has
its
issues
for
every
read,
that's
a
bit,
so
the
neutral
system
is
basically
based
on
this.
B
B
B
It's
a
big
difference
being
your
work
at
this
point.
There
isn't
much
it
suggested
in
rester.
We
have
her.
Checks
have
done
at
compile
time
so
here,
if
you
try
to
make
an
invalid
cast,
it
will
just
set
fault
when
you
run
it.
So
it's
inconvenient
to
discover
there
is
an
error
in
your
code
after
being
compiled
when
distributed
and
in
rest.
If
you
trace
the
same
just
in
the
type
which
isn't
the
children
of
a
window,
for
example,
a
button
is
the
children
of
a
widget,
but
there
isn't
a
bit
children
of
a
window.
B
If
you
try
it,
you
won't
compile.
You
will
get
an
error,
so
so
trait
isn't
implemented.
Therefore,
gtk
button,
it's
quite
convenient,
so
yeah.
Another
advantage,
of
course,
is
a
cut.
The
readability,
so
I
didn't
see
very
verbose
in
rest,
a
bit
less.
It's
the
advantage
of
object-oriented
languages
not
to
sell
you
in
here.
B
Some
buds
are
gangs.
Of
course
now
you
can't
have
arrays
which
have
invalid
size.
You
can't
forgive.
We
don't
allow
to
give
a
size
of
an
array
when
you
give
it
a
to
a
function.
It's
a
done.
An
array
is
a
5
pointer,
so
you
have
it's
a
Lancer
provided
by
the
type
a
directly,
so
no
need
give
the
size
anymore.
Very
convenient
and
402
have
a
lot
less
error
and,
of
course,
is
a
strong
type
system,
which
is
one
of
the
biggest
advantage
of
Resta.
B
So
you
can't
make
a
cast
whether,
however,
you
want
just
watch
the
function
in
it
now
at
this
point
to
what
remains
to
be
done.
Well,
I
think
we
are
around
90%
of
bindings
automatically
are
generated
and
the
most
of
missing
functionality
is
functions.
Objects
are
clearly
in
jio,
so
I'm
starting
to
write
new
things
in
it
directly,
we'll
see
how
much
time
it
takes,
hopefully
a
few
months.
No,
yet
we
started
recently
at
the
last
egg
nominal
rest,
a
quest
to
improve
the
a
synchronous
report,
which
is
a
very
aster
by
a
few
people.
B
B
We
have
still
a
lot
of
work
to
do
in
either,
so
it
will
be
the
next
step,
I
think
and
we
are
done
with
the
beginning,
so
beyond
the
dirs.
So
we
had
a
few
people
from
the
genome
community
very
interesting
interest.
We
started
a
few
a
quest
last
year
about
this
to
write
a
Signum
class
project.
For
example,
we
have
the
previous
talker
is
from
a
genome
and
yeah
Heidi.
B
A
B
B
B
We
are
on
little
details
now
having
a
duplication
having
you
more
drugs,
have
been
you
better,
interphase,
better
early
world
and
at
this
point,
how
we
could
we
do
to
make
it
even
better
and
Ranma
has
been
a
created
for
that.
It's
a
another
abstraction
another.
So
I
will
let
its
creator
speak
for
it.
So
I.
B
C
So
first
I'll
cover
some
pain
points
I
had
when
working
with
gdj
RS
by
developing
a
web
browser.
So
the
first
problem
I
had
is
when
you
want
to
associate
some
data
with
a
widget.
Let's
say
you
the
model
of
your
application
when
you
want
to
do
that
with
GTRs
because
of
the
safety
we
had
in
rust,
we
need
to
use
an
RC
ref
saw,
so
we
have
a
ref
content
value
that
we
want
to
check
the
be
able
to
borrow
a
check,
the
burrow
at
runtime.
C
C
So
one
thing
I
wanted
to
tell
you
that
if
you
can
avoid
using
ref,
though
it's
a
good,
it's
a
good
thing
to
avoid,
and
what
I
do
and
well
is
that
I
use
a
ref
cell,
but
I'm
just
not
telling
you
so
also.
You
can
do
asynchronous
programming
with
jellyband
stuff,
but
it's
not
very
ergonomic
and
I
wanted
to
integrate
realm
with
the
a
synchronous,
I/o
library
universe,
which
is
Tokyo
and
also
since
Russ
does
not
provide
inheritance.
C
C
So
realm
is
inspired
by
a
language
that
is
called
M
that
is
used
for
developing
client-side
application.
So
Elm
is
an
alternative
to
JavaScript
I
found
out.
It
provides
a
good
way
to
you,
a
Duhamel
view
controller.
So
that's
my
inspiration
for
realm,
so
in
annual
dictionary
model,
which
is
the
data
that
you
associate
with
a
view
and
you
have
an
update
function,
that
would
take
the
model
in
response
to
some
event
and
return
the
new
model,
and
you
also
have
a
view
function
that
describes
your
view
in
a
declarative
way
in
realm.
C
C
So
let's
see
how
we
can
use
run
first,
we
need
to
declare
a
model
which
is
a
normal
type
in
a
row,
so
it
could
be
a
struct
and
then
we
use
this
widget
attribute
an
info
of
widget,
which
is
the
trait
we
want
to
implement
and
for
a
window
in
this
case
which
will
create
a
window.
So
we
need
first,
the
model
meadow
which
declared
the
initial
model
of
your
widget,
and
then
we
have
messages
that
are
used
to
communicate,
for
instance,
between
widgets
or
having
a
message.
C
Hanwen,
there's
an
gtk
event
and
you
can
also
be
used
when
there's
a
synchronous
I/o.
So,
for
instance,
you
do
a
network
request
and
when
it's
done,
you
receive
a
message,
so
we
use
the
derive
while
the
custom
derived
message
and
we
have
an
enum
which
has
many
variants
that
can
have
a
value
and
then
we
have
the
view.
So
it's
still
in
the
Ambala
yet
and
we
use
the
view
macro,
and
we
now
have
the
this
declarative
syntax.
So
we
can
create
gtk,
widgets
and
nest
them
and
also
set
their
properties.
C
We
can
connect
the
clicker
and,
for
instance,
which
will
send
the
increment
message
in
this
case,
and
we
can
also
do
bindings,
meaning
that
a
last
line
we
have
the
text
property
the
of
the
label.
It
is
bound
to
an
attribute
of
the
model.
So
that
means
that
whenever
this
attribute
of
the
model
is
change,
that
will
update
the
view.
C
And
then
we
have
this
update
method,
so
it
takes
self
by
mutable
reference
which
has
access
to
the
model
that
we
can
modify
when
we
receive
a
message.
So
in
this
case,
when
we
receive
the
decrement
message,
we
just
change
a
counter
attribute
of
the
model
and
that
will
actually
update
the
view,
even
though
it's
not
shown
here.
C
So
the
widget
attribute
will
start
by
collecting
the
data
binding,
so
it
will
analyze
the
view
check
that
in
this
case
the
label
has
a
property
that
is
called
text
that
is
bound
to
the
contrary,
root
of
the
model,
and
then
it
will
actually
change
the
code.
You
write,
you
wrote
in
the
Med
update
metal
to
actually
update
the
view,
so
it
will
see
here
that
the
counter
attribute
was
changed
and
it
will
use
this
value
to
update
the
view,
because
it
noticed
that
there
was
a
bending
in
the
view.
C
So
even
though
I
use
attributes
ran,
can
work
on
stable
rows
because
I
used
a
hack
to
have
the
procedure
on
macro
to
work
and
the
future
of
run
will
may
be
without
futures.
Also,
I
will
work
to
improve
the
error
messages
because
at
the
time
I
first
started
run.
It
was
using
the
old
sink
right,
so
we
didn't
have
access
to
the
position
of
the
tag,
and
so
that's
why,
when
you
have
an
error
message,
it's
shown
on
the
widget
attribute,
which
is
not
convenient
and
I,
will
support
more
agility
features.
A
B
So
the
question
is:
take
this
one?
So
the
question
is:
how
does
rested
checks?
The
lens
of
arrays
at
compute
signed
its
slice.
It's
basically,
an
array
in
rest
is
a
slice.
So
in
the
type
you
have
the
pointer
where
it
starts,
and
you
have
its
length
in
the
same
point:
it's
what
we
call
at
pointers,
five
pointer.
So
when
you
give
it
to
a
function,
we
when
we
generate
a
ricotta,
we
we
we
just
know
the
size
of
the
slice.
B
A
B
C
A
B
B
So
at
this
point
yeah
it's
a
bit
complicated.
If
you
don't
know
how
gear
works.
Well,
even
if
you
know
it's
a
bit,
so
we
in
turn
the
in
the
few
more
weeks
to
make
something
better.
But
it's
more
like
when
we
have
a
new
someone
new
starting
a
new
library
using
the
idea
we
take.
What
it
says
is
missing.