►
From YouTube: Rust Linz, August 2020 - Rainer Stropek - Intro to Cargo
Description
C# has NuGet, Java has Maven, JavaScript has npm - and Rust has Cargo. Cargo is a package manager and build-tool. In this session, Rainer Stropek will introduce Cargo and demonstrate how to use it when building Rust applications. This will be an introductory talk for people who are rather new to Rust.
Rust Linz at https://rust-linz.at
Twitter: https://twitter.com/rustlinz
Rainer Stropek: https://twitter.com/rstropek
Speak at Rust Linz: https://sessionize.com/rust-linz
A
Next,
let's
say
30
to
45
minutes
we
will
see.
I
will
show
you
a
bunch
of
things
you
can
do
with
cargo.
This
is
probably
if
you
have
written
a
lot
of
rust
already.
I
will
not
tell
you
so
many
new
things.
If
you
are
rather
new
to
rust-
and
you
maybe
just
started
with
one
or
two
hello
world
projects,
then
I
hopefully
will
be
able
to
tell
you
a
lot
of
trip
to
a
lot
of
tricks
and
behind
the
scenes
stuff
about
cargo
and
so
on
and
so
on.
A
Before
I
go
any
further,
I
have
posted
the
material,
the
link
to
my
material,
the
slides,
the
samples
and
so
on
in
the
in
the
github
and
in
in
the
discord
channel.
Everything
is
mit
licensed,
so
please
take
my
slides.
Use
them
share
them,
build
on
them,
whatever,
whatever
you
want,
all
the
content
that
I
will
show
you
in
my
presentation
is
available.
Oh
this
is
this
link
only
works
in
in
github
life.
A
It
will
everything
will
be
available
in
in
markdown,
so
take
it
and
maybe
translate
it
into
whatever
you
want,
and
you
have
all
the
samples
in
the
sample
directory
on
the
github
repository
speaking
of
github.
This
is
the
repository
where
all
my
material
lives.
So
here
you
can
see
the
slides.
This
was
the
link
that
didn't
work
before
copy
them.
Do
whatever
you
want
with
them,
and
here
you
see
all
the
samples.
A
A
The
first
part
will
be
for
beginners,
okay.
Well,
it
will
be
for
people
who
have
not
written
so
much
rust,
but
I
hope
even
the
first
part
will
show
the
more
experienced
trust
developers,
some
new
tips
and
tricks,
and
then
in
the
next
chapters
we
will
dive
deeper
into
cargo.
So
first,
let's
quickly
introduce
cargo.
Let's
keep
that
very
short
and
to
the
point
it's
a
dependency
management
system.
You
manage
your
cargo.
Your
rust
dependencies
dependencies
are
called
crates
in
cargo
crate.
We
are
here
in
in
a
german
spoken
country.
A
In
austria,
crate
is
kiste
holzferschlag.
This
is
what
a
crate
is
all
about.
So
when,
when
we
are
talking
about
crates,
this
is
the
name
of
rust's
dependencies
packages,
but
cargo
is
more
than
just
dependency
management.
It's
also
a
helper
to
invoke
the
rust,
compiler,
the
documentation,
generator
and
so
on,
and
so
on.
So
it's
a
tool
that
makes
it
simple
to
pass
all
the
necessary
parameters
to
the
rust,
compiler
and
associated
tools.
A
So
if
you
would
like
to
start
something
from
scratch,
you
just
say
cargo
new
and
then
you
give
it
a
name.
Finally,
you
specify
bin
or
lib,
depending
on
whether
you
want
to
create
a
program
or
a
library.
Next,
you
go
into
the
generated
directory.
Here
you
call
cargo
build,
for
instance,
by
default.
This
uses
the
profile
dev.
You
can
define
the
details
about
different
profiles
with
cargo,
but
the
default
profile
creates
a
debug
version
of
your
code
and
then
you
can
simply
run
it
and
where
can
you
run
it
from
the
target
folder?
A
So
if
you
run
cargo
build,
you
will
find
a
new
folder
target
there.
You
will
find
the
name
of
the
version
you
are
generating
debug
release,
whatever
you
are
looking
for,
and
finally
the
executable-
and
here
you
see
how
you
can
run
this
one
with
cargo
build
release.
This
now
enables
all
the
different
optimizations
and
so
on,
and
finally,
you
can
run
the
release
version.
Please
note
here
the
link
here,
if
you
want
to,
if
you
want
to
tune,
fine-tune
the
different
profiles
for
cargo,
take
a
look
at
this
link.
A
I
only
have
45
minutes
or
so
today.
So
I
cannot
tell
you
everything
about
cargi.
You
still
have
to
do
a
little
bit
of
research,
but
at
least
the
least
I
can
do
is
give
you
some
links
where
you
can
read
more
details
if
you
need
them.
Okay,
this
is
a
very
quick
introduction
of
what
you
can
do
with
cargo,
but
there
is
much
more
here
I
put
I
put
together
a
table
with
the
most
important
cargo
commands.
A
Cargo
new
obviously
creates
a
new
package
can
be
a
library,
can
be
an
executable
cargo
search,
searches
for
a
crate
in
crates.I
o.
We
will
talk
about
this
website
in
a
second
cargo.
3
displays
a
nice
three
visualizations
of
all
your
dependencies
because
you
might
depend
on
a
crate
that
depends
on
the
crate.
That
depends
on
a
crate
and
so
on,
and
this
gives
you
a
like
visualization.
A
A
Cargo
run
and
cargo
build
without
ever
touching
the
network.
So
cargo
fetch
is
important
for
people
who
are
traveling
a
lot
good.
That
brings
me
to
the
typical
file
layout
of
a
project.
Let's
zoom
in
here
a
little
bit
here.
You
see
one
important
file
that
we
will
work
on
a
lot
in
the
upcoming
30
minutes,
or
so
it's
the
cargo
tamil
file.
A
They
define
some
metadata
about
your
application,
the
author
and
and
the
license
and
a
lot
of
other
stuff
and,
of
course,
your
dependencies
once
you
call,
for
instance,
cargo
build
a
cargo
lock
file
is
generated.
Maybe
the
node.js
developers
does
that
sound
similar
to
what
you
already
know.
Yes,
cargo
tomml
is
very
similar
to
package
json
and
cargo.
A
Lock
is
very
similar
to
package
lock
json,
so
the
cargo
log
file
is
generated
by
the
cargo
tooling,
when
all
the
dependency
resolution
is
done
and
cargo
lock
contains
a
lot
more
details
about
the
dependencies,
the
detailed
versions
and
the
dependencies
of
the
dependencies,
and
things
like
that
it
is
responsible
for
repeatable
builds.
So
if
you
just
take
cargo
tunnel,
you
don't
get
a
repeatable
build,
but
if
you
get
take
cargo
lock,
you
can
really
endure.
Repeatable
builds
and
also
it
makes
the
tooling
faster
this
on
the
same
directory
level.
A
You
also
have
your
source
code.
It's
here,
you
can
add
some
benchmarks.
Yes,
cargo
and
rust
have
a
benchmarking
mechanism
built
in
you.
Don't
need
third
party
tools
for
that.
You
can
add
examples,
and
I
personally,
when
I
got
into
cargo,
I
found
this
one
a
very
interesting
one.
There
is
a
dedicated
mechanism
of
adding
example
code.
You
know
this
is
this
is
very.
This
comes
in
very
handy
for
me.
When
I
build
libraries,
then
I
typically
do
a
kind
of
let's
say:
example:
driven
development.
A
I
design
my
libraries
while
I
am
thinking
about
different
scenarios
that
my
library
should
fulfill
and
now
I
can
write
the
example
code
in
the
same
folder
structure
and
it
fits
in
nicely
into
the
whole
project
structure.
I
really
find
this
one
very
interesting
and
finally
here
we
have
the
tests
but
important
one.
It's
called
tests,
but
it
doesn't
mean
unit
tests.
If
you
read
tests
directory,
it
means
integration
testing.
I
will
show
you
later
an
example
how
a
unit
test
looks
like
and
how
you
can
run
unit
tests
with
cargo.
A
Okay,
let's
talk
a
little
bit
about
the
cargo
tamil
file.
I
already
mentioned
it's
similar
to
npm's
package.json
file.
If
you
have
never
written
javascript
or
or
node.js
or
typescript
code-
and
you
don't
know
what
package
json
is-
don't
worry,
you
don't
need
to
know
that,
but
those
of
you
who
have
you
know
what
I
mean
the
file
has
to
be
called
cargo
tunnel
with
an
uppercase
c:
that's
defined.
Okay,
tommel.
It
stands
for
tom's,
obvious,
minimal
language
short
tunnel.
A
A
It's
built
on
semantic
versioning.
So
if
you
add
a
dependency
to
cargo
towel,
you
also
add
the
version
number
of
the
dependency
you
would
like
to
depend
on,
and
this
is
built
on
semantic
versioning.
So
again
here
I
added
the
link.
If
you
have
never
heard
about
semantic
versioning,
that
is
my
homework
for
you
read
this
document.
Semantic
versioning
is
super
important
in
every
modern
programming
language
that
I
know.
Okay,
so
here
is
the
link
and
it's
everything
is
built
on
semantic
versioning
here.
A
You
also
have
some
package
metadata
and
it
looks
like
this.
This
is
typical
package
metadata.
It's
the
name
of
the
package,
the
version
the
author
and
the
edition.
The
addition
is
something
that
new
that
beginners
with
rust
are
sometimes
a
little
bit
confused.
The
edition
is
not
your
edition
of
library.
It's
the
addition
of
rust
that
you
would
like
to
work
with
and
2018
is
currently
the
the
latest
stable
release
that
you
can
use
and
down
there.
You
will
find
some
dependencies
we'll
talk
about
that
in
a
second.
A
A
Well,
it
depends
if
you
build
an
end
product,
you
typically
care
for
consistent
builds.
You
would
like
to
build
an
end
product
that
really
has
specific
dependency
versions
baked
in
and
then
you
check
in
the
cargo
log
file.
If
you
are
creating
a
library,
you
typically
do
not
check
in
the
cargo
log
file,
because
the
the
choosing
of
the
detailed
version
is
done
by
the
end
product
using
your
library.
If
you're
not
confused,
well,
take
a
look
at
this
link
here,
you
can
find
all
the
details
in
the
cargo
frequently
asked
question
lists.
A
I
don't
have
the
time
to
go
into
further
details,
but
just
remember
the
drool
of
thumb
end
products
check
it
in
libraries,
don't
check
it
in
then.
You
are
typically
out
of
the
problem
space
with
that.
Let's
take
a
look
at
my
first
example
just
to
let
you
know
my
my
examples
here
are
written
in
a
kind
of
hands-on
lab
style.
I
always
do
that
when
preparing
some
some
some
talks,
so
you
can
take
these
hands-on
labs
for
your
own
practice.
Just
don't
take
a
look
at
my
solution.
A
You
can
take
a
look
at
my
solution
if
you
are
stuck
somewhere,
but
if
you
are
doing,
for
instance,
in
your
company,
rust,
hackathons
or
if
you
are
a
teacher,
and
you
would
like
to
to
teach
some
some
lectures
about
rust
or
if
you
are
a
trainer
giving
a
rust
training
take
a
look
at
my
hands-on
labs
feel
free
to
copy
them
to
extend
them,
do
whatever
you
want
with
them,
okay,
but
I
will
now
walk
you
through
this
example,
because
we
are
sitting
here
together
and
let
me
quickly
start
visual
studio
code
in
my
samples,
folder-
and
here
we
are-
this-
is
the
sample
this
this
one,
the
zero
one
intro.
A
This
is
a
sample
that
I
would
like
to
show
you.
Okay,
the
the
code
is
very
simple
and,
let's
start
with
the
cargo
tomml
file
here,
the
important
stuff
that
is
going
on
here
is
in
the
dependency
section.
As
you
can
see
it
here,
I
have
two
dependencies.
One
is
regex,
because
this
sample
does
something
with
regex
and
the
second
one
is
lazy.
Static,
lazy,
stating
is
an
interesting
dependency.
A
It
allows
you
to
initialize
something
in
a
lazy
fashion,
but
statically.
So
in
my
case
I
would
like
to
compile
a
regular
expression,
but
only
once
and
every
time
I
execute
the
code
again,
I
would
like
to
access
the
compiled
regular
expression,
and
this
can,
for
instance,
be
can't,
for
instance,
be
done
with
this
package.
A
If
I
hover
over
this
thumb,
I
see
all
the
different
versions
of
my
dependency.
To
be
honest,
this
is
an
extension
here.
I
will
not
go
into
the
details.
You
will
probably
find
it
on
your
own.
If
you
just
take
a
look
at
the
extensions
in
visual
studio
code
here
and
just
type
in
cargo
or
crates,
then
you
will
find
a
lot
of
extensions
in
this
case.
A
Okay,
now
good
thumbs
up
again.
If
we
take
a
look,
a
quick
look
at
the
source
code,
you
see,
the
source
code
is
pretty
standard
at
the
beginning,
I'm
using
a
standard
io.
This
is
part
of
the
rust
standard
library.
You
don't
need
to
add
an
explicit
dependency
to
rust,
standard
library.
It's
always
available
with
some
exceptions.
I
know
it
it's
possible
to
program
without
it,
but
that
would
be
the
exception
of
the
rule.
Generally
speaking,
you
always
have
a
dependency
on
the
rust
standard
library.
You
don't
need
to
add
that
to
your
toml
file.
A
Here
we
see
the
two
use
statements
which
refer
to
the
dependencies
that
we
have
added
in
our
cargo
toml
file
and
this
example
is
pretty
simple:
in
an
endless
loop,
I'm
asking
asking
the
user
to
enter
some
text.
If
the
text
is
quit,
we
will
stop
the
program.
Otherwise,
I'm
going
to
call
this
method
down.
A
Here
is
proper
date,
and
here
you
see
here,
I'm
using
the
lazy
static
macro
which
allows
me
to
lazily,
compile
for
a
single
time,
the
regular
expression
and
then
I'd
just
call
the
is
match
to
tell
the
user
whether
he
or
she
has
just
entered
a
valid
date.
Let's
try
this
application
first.
Well,
I'm
going
into
the
folder
and
I
say,
cargo
build.
This
will
build
my
application.
I
consciously
deleted
my
target
folder.
A
So
therefore,
you
see
what's
going
on
here,
it's
fetching
stuff
from
crates.io
and
it's
now
building
compiling
the
dependencies
and
it's
also
compiling
my
application.
Now
it's
done,
and
I
can
just
cargo
run
it,
and
here
you
see
I
can
enter
something.
This
is
not
a
date,
but
if
I
enter
something
like
this,
it
says
it's
a
date.
So
the
application
is
working.
We
have
two
dependencies
in
our
cargo
tamil
file
and
we
have
seen
how
cargo
helps
us
to
to
build
the
application
in
this
case,
in
a
debug
version.
A
A
If
we
take
a
look
here
in
the
the
target
folder,
then
you
will
see
that
we
find
a
lot
of
interesting
stuff
here,
and
here
you
essentially
see
where
the
dependencies
are
stored
or
at
least
versions
of
the
dependencies
are
stored.
I
will
not
go
into
the
internal
details.
How
this
stuff
is
is
stored
in
details.
To
be
honest,
I
don't
absolutely
know
what's
going
on
behind
the
scenes,
but
at
least
you
can
see
that
the
dependencies
are
here
in
the
target:
folder.
Okay,
good
first
sample.
A
Let
me
check
if
I
did
everything:
yes,
okay,
good
next
one
workspaces
workspaces
was:
they
were
something
new
for
me
as
a
javascript
developer,
partly
as
a
c-sharp
developer.
I've
spent
most
of
my
work
working
with
c-sharp,
javascript,
typescript
and
all
this
stuff
and
workspaces
are
a
really
neat
thing.
What
you
can
do
is
you
can
create
a
collection
of
more
packages
in
a
kind
of
folder
structure,
for
instance,
if
we
take
a
look
at
my
for
my
samples
folder
here,
this
is
in
fact
a
workspace.
A
You
see
we
have
on
the
top
level.
Here
we
have
a
separate
cargo
tamil
file.
You
see
that
one.
So
if
I
check
the
cargo
tomml
file
here,
we
see
that
we
have
some
members.
So
my
samples
workspace
consists
of
multiple
in
this
case
binaries
or
even
libraries,
and
they
are,
they
are
commonly
maintained
inside
a
workspace,
and
the
important
thing
here
is
that
they
share
a
common
output
directory.
A
You
can
see
it
here
target,
so
what
I
can
do
is
I
can
cargo
build
all
my
projects
in
all
my
subdirectories,
which
belong
to
my
workspace
with
a
single
cargo
build
it.
I
happened
to
add
a
unit
test
in
one
of
my
libraries,
so
I
can
also
call
cargo
test.
I
will
tell
you
more
about
that
in
a
second
and
run
the
unit
tests.
A
Another
important
thing
is
that
you
have
a
central
cargo
tomml
file,
so
they
share
the
same
dependency
resolution,
so
they
share
a
cargo
log
file.
That
means
that
if
you
have
two
different
libraries-
and
they
refer
both
to,
for
instance,
something
like
rand
the
crate
for
random
number
generation,
then
both
of
them
will
rely
on
the
same
version.
The
system
will
pick
the
same
detailed
version
of
this
dependency
for
all
the
libraries
inside
this
one
workspace.
A
So
this
is
what
workspaces
are
all
about,
and
here
I
have
added
the
github
link
where
you
can
take
a
look
at
my
samples,
workspace
that
should
be
enough
for
getting
started,
and
now
we
can
dive
a
little
bit
deeper
into
dependencies
and
what
you
can
do
with
dependencies
and
believe
me,
if
you
come
from
the
javascript
world,
and
you
have
done
a
lot
of
package
json
magic,
then
you
will
now
recognize
even
more
magic,
which
is
going
on
in
cargo,
knows
a
lot
of
very
interesting
tricks
here.
A
As
I
said,
dependencies
are
called
crates,
and
here
you
see
this.
This
is
the
german
kiss
that
holds
fishlock
okay.
So
where
can
I
get
my
crates
from
first
and
most
commonly
you
get
them
by
specifying
a
simple
version
number,
and
that
means
that
you
get
your
crates
from
crates
dot
io.
If
we
take
a
look,
this
is
crates
dot
io,
and
here
you
can
look
for
a
specific
crate.
Let's
check,
for
instance,
this
one,
it's
the
random
number
generator,
and
here
you
see
you
get
a
bunch
of
description.
A
You
can
take
a
look
at
the
detailed
documentation.
You
see
the
dependencies
you
see
the
repository,
the
project
can
specify
a
home
page
and
so
on
and
so
on.
So
this
is
by
just
specifying
a
version.
I
will
show
you
details
later
on
what,
if
you
have
some
private
libraries
that
you
don't
want
to
share
publicly?
You
can
set
up
a
custom
registry
and
all
you
need
for
that
is
just
a
git
repository
at
the
end
of
the
day,
the
cargo
tooling.
A
It
can
get
your
crates
from
any
arbitrary
git
repository
that
you
have
inside
of
your
local
area
network,
for
instance.
So
it's
super
simple
to
set
up
a
custom
registry.
There
are
also
offers
third-party
offers,
for
instance,
from
cloudsmith,
where
you
can
rent
some
private
crates
repository
space
in
the
cloud.
If
you
want
I've
added
some
links
here
again
follow
the
links
and
you
can
read
more
details.
A
But
now
comes
the
interesting
part.
We
can
also
pick
some
crates
directly
from
git,
so
we
can,
instead
of
specifying
a
version,
just
specify
a
git
link,
and
then
the
cargo
tooling
will
get
clone.
The
repository
look
for
a
cargo
tamil
file,
there
compile
the
whole
stuff
and
add
it
as
a
dependency
to
your
application.
So
you
can
have
a
direct
git
dependency.
Using
cargo.
Same
is
true
for
local
folders.
A
You
can
add
a
path
dependency
instead
of
a
version
number
and
then
the
create
the
cargo
tooling
will
look
into
this
path
and
it
becomes
even
more
interesting
one
additional
thing
that
I
have
for
you
is:
you
can
specify
multiple
sources,
and
that
becomes
very
interesting,
because
then
you
can,
for
instance,
say
cargo.
You
know
what
by
default,
take
this
version
from
crates.io,
but
if
I
also
have
a
local
version
of
my
library
here
inside
of
this
path,
take
this
path.
If
I
run
it
locally.
A
That
means
that
I
can
work
on
a
local
version
of
my
library,
which
is
not
published
to
create
dot
io
yet,
and
I
can
override
the
the
dependency
with
a
local
version,
where
I
can
maybe
add
some
some
bug
fixes
or
additional
functionality.
It
becomes
pretty
simple
to
work
with
libraries,
while
you
are,
while
you
are
pulling
it
up.
While
you
are
working
on
this
library
and
overriding
some
sources
which
later
come
from
when
everything
is
done
from
crates.io,
that's
the
idea
of
passing
on
multiple
sources,
I
will
show
you
an
example
later
now.
A
We
also
have
different
dependency
types.
This
is
pretty
obvious,
so
I
will
keep
it
short.
You
have
dependencies
regular
dependencies.
You
have
depth
dependencies,
they
are
only
used
for
compiling
tests,
examples
and
benchmarks,
and
then
you
have
build
dependencies
which
are
only
used
for
build
scripts.
A
A
I
simply
had
to
skip
some
things,
because
otherwise
my
talk
would
have
taken
four
hours,
so
simple
ones,
referencing
crates.io!
Here
you
see
some
references
to
crates.io
random
number
generators,
number
of
cpus.
I
want
to
find
out
the
number
of
cpus
and
number
formatting
very,
very
simple,
and
here
at
the
end,
you
have
some
version
selector,
and
this
is
what
I
would
like
to
talk
a
little
bit
about
how
this
this
works.
I
already
showed
you
this
example.
A
Publishing
crates
will
be
an
example
at
the
end
version
references,
as
I
told
you
are
based
on
sambar.
That
means
the
first
thing
that
you
can
do
is
very
similar
to
javascript
and
node.js.
You
can
have
so-called
carrot
requirements.
A
Carrot
is
this
nice
little
character
here,
and
it
just
gives
you
the
latest
minor
version
for
the
specified
major.
So
in
this
case
it
gives
you
something
between
1,
2,
3
and
2.0.0,
excluding
so
one
point
x,
point
x.
This
is
what
a
carrot
requirement
does
the
tilde
requirements.
Tilde
is
the
character
here
is
similar,
but
it
only
works
here
on
the
on
the
minor
version.
So
if
you
specify
one
two,
three,
you
get
something
between
one
two,
one,
two
three
and
one
three
excluding
so
you
get
one
two
star.
A
You
can
also
write
some
wildcard
requirements.
I
think
it's
pretty
obvious
what
one
dot
star
does
and
you
can
also
add
some
comparison
requirements,
something
like
greater
equal
1.2.0,
that's
possible
too.
If
you
want
to
use
that,
because
carrot
and
tilde
requirements
are
too
complicated.
This
is
maybe
easier
to
read
but
be
aware.
There
are
some
limitations.
If
you
would
like
to
publish
your
crate
on
crates.io,
you
can't
use
parts
of
the
comparison
requirements
and
wildcard
requirements.
A
If
I
can
remember
that
correctly
so
check
that
out,
maybe
you
will
get
an
error
with
the
carrot
requirements
and
the
tilde
requirements.
You
are
on
the
safe
side,
good
now,
what's
going
on
behind
the
scenes?
What
is
this
crates.I
o?
Essentially
crates.io
is
a
big
index
in
github.
You
see
this.
Is
this
indexing
github?
So
here
you
see
the
first
two
letters
of
all
the
different
crates
which
are
available
on
crates.io.
A
For
this
talk
I
published
one
on
my
own.
It's
called
m
mth
calc
for
multi-threaded
calculation.
So,
let's
look
here
in
mt-
and
here
I
find
the
h
underscore-
and
here
it
is.
This-
is
the
example
that
I
published
for
this
talk.
May
I
think,
somewhere
in
last
week-
and
here
you
see
the
different
versions
of
this
mth
and
so
on.
This
is
the
index
of
all
the
crates.
A
Okay,
so,
and-
and
if
you
want
to
build
your
own
custom
crates
repository,
then
you
have
to
set
up
something
similar
but
of
course
checking
all
this
stuff
inside
of
git
repositories
is
not
very
convenient.
Therefore,
a
fully
blown
crates
repository
like
crates.io
offers
a
restful
web
api
with
which
you
can
look
for
crates
and
find
also
their
download
locations,
so
they're
just
tar
balls
at
the
end
of
the
day.
A
So
if
we
take
a
look
at
this
one,
for
instance,
this
is
a
very
simple
give
me
all
crates
query
that
I
send
here
and
you
see
all
the
different
crates
with
some
download
links
and
so
on
and
some
meta
information.
You
can
also
pass
in
some
queries.
For
instance,
I've
done
that
here
you
can
see.
I
go
up
here
again,
I'm
looking
for
the
sample
crate
that
I
created
for
this
talk
and
the
second
one
happens
to
be
exactly
my
example,
crate
that
I
published
two
days
ago
and
you
see
yeah.
A
It's
just
a
demonstrating
cargo
and
it
was
published
by
me-
and
you
see
that
here
so
this
is
what
crates.io
is
behind
the
scenes.
It's
a
web
api
on
top
of
a
package
index
stored
in
github
and
a
bunch
of
tarballs
sitting
somewhere
on
the
internet
in
the
crea
in
the
cargo
documentation.
You
can
find
details
about
how
to
replicate
the
whole
package
repository
if
you
want
to
have
a
copy
in
your
own
local
area
network
or
things
like
that.
Please
consult
the
documentation.
A
If
you
would
like
to
do
something
like
that
with
that,
let's
again
take
a
look
in
another
example,
we
will
focus
on
the
cargo
stuff,
but
it
hopefully
contains
some
interesting
stuff
for
you
too.
So
what
I
did
here
is
I
made
a
mistake.
Consciously
you
see
here,
I
was
specifying
a
tilde
requirements
which
tells
the
system
essentially
give
me
something
1.0
anything
and
now
my
tooling
tells
me
hey
rhino.
A
There
is
already
a
1.13,
so
what
I
can
do,
for
instance,
I
can
do
something
like
this
change,
that
to
a
carrot
requirement,
and
what
did
I
tell
you
this
will
now
give
me
the
latest
1.x
dependency.
So
now
my
tooling
tells
me
everything
is
fine.
You
will
get
the
1.13
version
of
this
library
sounds
good.
Let's
take
that
one.
In
that
case,
I'm
having
here
a
random
number
generator,
I'm
asking
for
the
number
of
ctus
and
cpus
and
I'm
doing
some
number
format,
essentially
what
I
did
for
this
sample.
A
It's
very
similar
I
calculated
pi
I
like
to
do
that.
I
like
to
calculate
pi,
but
in
a
very
special
way,
I'm
doing
a
monte
carlo
simulation
to
calculate
pi
if
you're
not
familiar
with
monte
carlo
simulation
monte.
Carlo
simulation
is
very
simple.
A
If
I
ask
you,
what
is
the
probability
to
get
a
3,
if
you
are
rolling
a
dice,
you
will
probably
say
3,
6
right
of
course,
but
if
I
give
you
a
real
physical
dice
and
you
are
not
sure
whether
it
was
manipulated-
and
I
ask
you
the
same
question
again
then
the
only
thing
you
can
do
is
let
it
roll
a
lot
of
times
count
the
results
and
apply
a
little
bit
of
statistics,
and
this
is
what
this
example
does.
It
takes
a
normal
circle
and
a
unit
circle
with
the
radius.
A
One
takes
a
lot
of
random
points
and
calculates
the
ratio
of
points
within
the
unit
circle
and
outside
of
the
unit
circle,
and
this
ratio
multiplied
by
four.
If
you
only
take
a
quarter
of
the
circle
is
pi.
This
is
monte,
carlo
and,
of
course,
this
is
a
problem
where
you
can
do
a
lot
of
multi-threading,
so
I
thought
it
would
be
interesting
for
you
to
see
how
we
can,
for
instance,
use
the
multi-threading
stuff
here
here.
A
I'm
spawning
some
threads,
but
the
important
thing
for
my
talk
here
is
that
we
are
here
accessing
the
libraries
where
I
edit
the
references
in
my
cargo
tunnel.
Here
you
can
see
I'm
referencing
the
random
number
generator
here,
the
number
format,
and
here
the
number
of
cpus,
and
what
I
do
essentially
here
is
I'm
spawning
as
many
threads
that
I
have
cpus
and
I'm
generating
a
lot
of
points
and
at
the
end
of
the
day
I
should
get
something
in
the
ballpark
of
pi.
A
A
Cargo
is
smart
when
it
comes
to
incremental
building
it
recognized
that
nothing
has
changed,
so
it
is
super
fast
and
we
can
immediately
cargo
run
the
whole
thing
and
it's
now
running
running
running
for
a
bunch
of
seconds
and
at
the
end
of
the
day
I
get
3.1418.
It's
not
pi.
Yet
because
I
only
did
7
million
or
8
million
calculations
per
second,
but
still
it
gives
me
something
near
pi,
but
I
want
to
show
you
the
same
example
with
cargo
build
release.
A
I
heard
ryan
talking
about
the
difference
between
debug
and
release
version,
and
I
would
like
to
demonstrate
that
here
with
this
performance
oriented
example:
let's
release
build
it.
Of
course
it
has
to
rebuild
all
my
dependencies
now
optimized
for
performance,
and
now
we
can
cargo
running
again.
Cargo
run.
A
A
So
this
is
what
ryan
meant
when
he
said,
don't
forget
to
compile
your
stuff
in
release
mode,
because
there
is
a
huge
difference
between
rust
and
cargo
building
for
debug
versions
and
rust
and
cargo
building
for
release
versions.
This
is
what
I
wanted
to
show
you
here
just
to
highlight
some
cargo
features.
Now
we
have
the
dependencies
and
we
have
the
release
builds.
This
was
this
example.
A
What
if
I
take
my
feature
that
I
can
run
a
certain
mathematic
algorithm
in
parallel
on
all
my
cpu
cores
and
put
them
into
a
separate
library-
and
this
is
what
I
did
here-
I
took
out
one
function
of
my
application
and
I
have
put
it
into
a
separate
crate
in
a
separate,
no,
not
a
crate
in
a
separate
package
which
is
a
subdirectory
of
my
cargo
tunnel,
which
is
the
binary
that
I
would
like
to
be
able
to
run
here.
You
see
it
has
its
own
source
directory
it
has
is
had.
A
Is
it
has
its
own
cargo
thermal
file?
And
here
you
see
the
implementation
of
my
library,
and
here
I
am
referencing
exactly
this
path,
so
I'm
getting
the
library
from
a
sub
directory.
Let's
take
a
look
at
this
example
in
real
life.
Here
it
is
here.
You
see,
I
have
my
cargo
tunnel
with
the
path
here
and
if
I
zoom
in
a
little
bit,
then
you
will
see
that
this
path
points
up
to
here.
A
If
I
open
this
one
here,
I
have
the
implementation,
and
here
you
see
the
dependency
of
my
library.
It
needs
the
number
of
cpus.
This
is
no
longer
a
dependency
of
my
binary,
which
calls
my
library,
because
the
binary
is
not
interested
in
the
number
of
cpus.
That's
an
implementation
detail
of
my
library
if
we
take
a
look
at
the
source
code.
This
is
what
I
did
and
please
note
this
is
what
ryan
already
mentioned.
A
I
will
not
go
into
the
details
of
the
implementation.
All
it
does
is
it
gets
the
number
of
cpus
on
my
system.
It
spawns
the
exactly
same
number
of
threads.
I
know
this
is
not
perfectly
optimized,
but
I
think
you
get
the
point
and
at
the
end
it
aggregates
the
results
by
iterating
over
the
results
of
the
thread
and
returns,
the
the
result
and
the
number
of
cpus,
that's
all
it
does,
and
here
at
the
end
I
have
a
unit
test
for
that.
So,
let's,
let's
play
a
little
bit
with
this
example.
Here.
A
So
I
have
to
close
it
here.
Okay,
so
let's
go
into
my
folder
here
and
let's
cargo
run
the
application
just
to
make
sure
that
it
still
works.
It
calculates
pi
slowly
because
it's
debug,
but
it
calculates
something
near
pi
if
I
say
cargo
test
and
that's
the
next
tool
that
I
wanted
to
show
you
this
one.
It
runs
no
unit
test
because
I'm
now
not
in
the
workspace
folder,
I'm
in
the
binary
folder.
But
if
I
go
into
the
library
folder
here
and
run
cargo
test
again,
everything
is
fine.
A
Than
is
lower
than
one
or
lower
than
the
something
like
this,
let
me
see
if
I
can
screw
it
up,
no,
it
doesn't
make
sense.
Okay,
I
will
not
do
ad
hoc
changes
to
you.
Can
you
can
try
it
on
your
own?
It
really
executes
the
test.
It
really
works
fine.
So
what
you
have
learned
here
is
these
path
dependencies.
A
A
This
is
how
a
git
dependency
looks
like
and
it
happens
to.
I
happen
to
have
this
example
here.
This
is
exactly
the
same
application
that
you
saw
before,
but
now
I
have
my
small
little
library.
I
pushed
it
onto
github,
so
it's
available
here,
you
can
take
a
look
at
it.
It's
say
exactly
the
code
that
I
shown
you
and
now
I'm
having
a
git
dependency
in
my
application.
I
no
longer
have
this
subfolder
here
on
the
same
level,
I'm
having
a
git
dependency.
Let
me
show
you
how
this
works.
A
A
A
This
is
pretty
neat.
I
liked
it
when
I
discovered
that
looking
into
the
details
of
cargo
yeah,
I
already
showed
you
that
one.
There
are
some
advanced
topics
which
I
cannot
cover
because
in
the
last
let's
say,
15
minutes
or
so
or
10
minutes.
I
want
to
show
you
something
completely
different.
These
advanced
topics.
You
will
probably
not
need
them
when
you
get
started
with
rust,
but
over
time
you
will
need
them.
So
I
would
like
to
tell
you
how
this
works
this
feature.
A
I
already
mentioned
it
multiple
times,
so
this
is
how
you
would
write
it
in
your
tomal
file.
You
specify
a
version
number.
This
version
will
be
taken
if
you
publish
your
library
as
a
create
to
creates.io,
but
you
can
have
a
local
version
of
the
dependency
in
a
certain
folder
and
therefore
have
some
additional
debugging
capabilities,
and
things
like
that,
the
next
one
is
overrides
overrides
are
even
more
advanced
as
this
specifying
multiple
locations
in
this
area.
A
If
you
want
to
know
all
the
details
about
overwriting,
if
you
want
to
go
all
in
into
library
development
and
you
have
to
develop
patches
for
your
libraries-
definitely
check
out
overrides,
I
added
the
documentation
link
here.
Please
excuse
that.
I
will
not
go
into
details
here
because
of
time
limitations.
A
Finally,
you
can
also
have
platform
specific
dependencies.
So
in
this
case,
if
your
target-
and
if
you
build
the
target
with
the
configuration
windows,
you
might
have
different
dependencies
than
if
you
target,
for
instance,
linux
or
something
like
this
features,
features
are
interesting.
Your
your
dependencies
can
have
optional
parts
which
are
called
features,
and
if
you,
if
you
have
a
dependency
on
a
library
which
offer
features,
then
you
can
add
opt-in
or
opt-out
from
these
features
and
depending
on
that,
the
package
behaves
differently.
A
Maybe
you
have
a
certain
package
which
can
optionally
offer
some
features
to
to
convert
something
to
pdf,
but
you
can
opt
in
or
opt
out
of
this
feature.
Maybe
you
don't
need
pdf
support
in
your
binary.
Then
you
can
opt
out
from
this
feature.
This
is
what
optional
dependencies
and
features
are
all
about
and
finally
build
scripts
build
scripts
are
great
great.
They
are
essentially
a
rust
application.
A
A
specific
file
which
is
in
the
root
of
your
package
folder
and
this
build.rs
file
is
compiled
and
executed
before
cargo
is
building
the
package.
So
you
can
do
a
lot
of
crazy
stuff
in
this
build.rs
file.
You
can,
for
instance,
build
some
c
dependencies
c.
Libraries,
you
can
generate
code
on
the
fly.
You
can
encode
find
out
some
platform,
specific
configuration
settings
and
change
them
before
you
apply
these
settings
when
you
compile
your
package,
so
this
is
what
build.rs
is
all
about.
A
We
have,
I
think,
some
with
something
like
10
minutes
left,
and
I
would
like
to
go
into
my
last
big
topic
here
for
the
last
10
minutes,
and
that
is
publishing
crates.
What,
if
you
create
a
library-
and
you
would
like
to
share
it
with
your
peers-
you
would
like
to
share
it
with
the
world.
What
do
you
have
to
do?
A
First,
you
need
to
learn
some
new
cargo
commands
cargo
login
cargo
package
and
cargo
publish
not
yes,
not
that
much,
of
course,
with
cargo
login
you
can
authenticate
against
crates.I
o
with
cargo
package.
You
can
build
your
library
into
a
tarball
and
with
cargo
publish
you
upload
everything
to
the
registry.
A
Now,
what
do
you
have
to
do
if
you
would
like
to
publish
a
crate
into
crates.I
o
or
your
custom
crates
repository
first
get
an
api
token
from
crates.io
yeah.
I
think
that's
simple,
then
add
some
meaningful
metadata.
Add
a
readme
file.
Things
like
that,
add
a
name,
a
description
and
I
think
you
get
the
idea.
Finally,
if
you
want
to
be
a
good
citizen,
add
some
unit
tests,
maybe
optionally,
add
some
integration
tests.
Add
some
benchmarks.
Add
some
example
code,
something
like
this.
Depending
on
the
necessarities
of
your
libraries.
A
You
have
to
invest
more
or
less
time
in
these
areas.
At
least
you
should
add
a
bunch
of
unit
tests
document
your
api,
including
examples,
and
I
will
show
you
more
about
that
in
a
second
when
we
go
into
my
last
hands-on
lab
and
finally,
you
use
cargo
to
publish
everything.
The
first
step
you
can
see
it
here
is
you
run
a
dry
run.
Version
of
cargo,
publish
dry
run,
means
that
it
does
everything
except
to
really
publish
it.
So
you
will
get.
You
can
check
your
package,
your
setup
for
potential
failures.
A
You
can
check
the
content
of
your
package
by
doing
cargo
package
list.
It
will
show
you
what's
in
your
package.
Of
course
we
want
our
package
to
be
small
and
therefore
we
want
to
check
out
whether
really
only
the
necessary
things
are
inside
of
our
package.
Maybe
we
have
added
some
larger,
let's
say
text
or
html
files
which
shouldn't
be
part
of
packaging.
Then
we
will
recognize
a
mistake
like
that
and
finally,
you
upload
everything
using
cargo
publish.
This
is
the
workflow
that
you
have
to
follow
with
that.
A
Let's
spend
a
few
more
minutes
in
another
example
that
I
have
prepared
for
you:
let's
open
visual
studio
code
with
this
version
of
my
great
mathematic,
multi-threaded
calculation
library.
I
know
it
doesn't
make
so
much
sense,
but
I
thought
it
would
be
a
good
idea
to
have
it
here,
so
this
is
now
a
crate
that
I
would
like
to
publish
on
crates.io.
I
already
have
published
it,
so
I
can
show
it
to
you
in
a
second.
This
is
what
the
tomal
file
looks
like.
Obviously
I
added
a
bunch
of
more
metadata.
A
I
don't
think
that
I
have
to
describe
all
the
things
here.
You
can
take
a
look
at
my
github
repository.
I
read
the
docs.
These
are
my
dependencies.
I
don't
have
to
talk
a
lot
about
that.
In
this
case,
I
get
a
warning
that
I
already
would
have
a
1
or
13,
but
I
it
happens
that
I'm
fine
with
that.
But
now
comes
the
interesting
stuff
in
my
example
code.
A
I
will
show
you
that
in
a
second
I
have
an
example
that
describes
how
to
use
my
library
and
this
example
is
using
a
random
number
generator
in
that
case,
I'm
not
adding
a
dependency,
but
I'm
adding
a
depth
dependency,
because
this
is
something
that
my
final
version
of
the
crates
does
not
depend
on.
It's
only
the
examples
you
might
ask
yourself,
hey
reiner
examples,
aren't
examples,
just
documentation
and
that's
a
big
wow.
That
was
a
big
wow
effect
for
me,
as
somebody
who
who
was
was
new
to
to
these
features
of
cargo
example.
A
Code
is
executable
documentation.
So
let's
go
into
that
one,
because
I
think
it's
really
really
great.
If
we
take
a
look
at
the
library,
then
you
will
see
that
I
have
some
example
code
here
inside
of
my
structured
documentation
of
my
function
and
believe
it
or
not.
I
can
run
these
examples.
I
can
build
these
examples.
I
can
even
add
here
you
can
see
that
one
hidden
code
which
contains
unit
testing
code,
which
will
not
be
part
of
the
documentation,
but
it
helps
me
to
verify
that
all
my
documentation
examples
still
work.
A
Let
me
show
you
that.
Let
me
show
you
how
this
looks
like
I
can't
do
the
following.
I
can
say
cargo
test
dash
dash
dock,
and
that
is
now
running
my
embedded,
my
embedded
code
here
in
my
documentation
area.
So,
for
instance,
let's
say
if
it's
smaller
than
one
something
like
this
doesn't
make
much
sense.
Let's
run
it
and
it
crashes.
Yes,
it
crashes
it.
I
now
ran
parts
of
my
documentation
using
the
cargo,
the
cargo
toolset,
and
the
same
is
true
for
for
building
this
stuff
and
and
all
these
things.
A
A
Now,
what
else
can
we
do
with
this
stuff?
If
we
have
nice
documentation,
we
can
run
cargo
dock.
If
we
run
to
cargo
dock,
then
we
get.
Let
me
quickly
open
this
one
here
in
explorer.
If
I
go
into
target
and
here
into
dock,
I
will
now
see
here
an
index.html
and
I
will
get
a
nice
little
human
readable
documentation
about
my
my
my
crate.
If
I
go
here,
you
will
see
the
documentation
from
my
rust
file,
and
here
you
can
see
this
nice
little
example.
A
This
is
exactly
the
example
that
I
showed
you
a
few
minutes
ago
inside
of
my
of
my
rust
code.
Okay,
so
crate
cargo
dock
is
a
built-in
api
documentation
engine
which
comes
in
really
nicely.
If
you
are
building
reusable
libraries,
because
we
all
know
that
a
library
is
only
as
valuable
as
its
documentation,
because
if
you
have
no
documentation
or
poor
documentation,
how
should
people
find
out
how
your
library
works?
And
I
think
this
is
really
nice?
Well,
obviously,
you
can
also
add
some
unit
tests
to
your
library,
just
as
we
had
before.
A
I
will
not
go
into
the
details
here.
So
if
we
now
run
cargo
publish
dry
run
this
one
yep
everything
is
good,
it
builds
it
yes
and
fine.
You
see
no
mistakes,
if
I
would
have
some
mistakes,
for
instance,
if
I
would
have
forgotten
some
mandatory
metadata
in
my
package
section
here,
I
would,
I
would
have
gotten
an
an
error
and
if
I
leave
out
the
dry
run,
it
really
publishes
everything
on
crates.I
o,
and
this
is
what
I
already
did.
A
So
if
I
go
to
create
start
io
and
I'm
looking
for
multi-threaded
calculation,
this
is
the
example
that
I
created
for
you.
Then
you
will
see
this
is
now
the
content
of
my
readme
file.
Here
you
have
all
my
meta
information
that
I
added
to
the
cargo
tamil
file.
I
can
go
to
the
documentation
and
that
leads
me
to
docs.rs
with
the
name
of
my
crate,
and
I
didn't
have
to
do
anything
for
that.
It
was
done
automatically
just
by
uploading.
A
My
crates.to
crates.io
it
automatically
takes
the
dock,
generates
the
documentation
for
me
and
publishes
here
on
on
docs.rs
and
here
just
to
prove
a
point.
You
see
the
public
documentation
of
my
sample
calculation
here.
So
this
is
the
result
of
me
publishing
my
crate
from
a
different
github
repository
okay,
so
you
see
the
readme
file
with
the
documentation
and
so
on.
A
If
you
are
interested
into
more
details,
please
take
a
look
in
my
github
repository
and
in
my
slides
and
the
hands-on
labs.
So
we
are
already
at
the
end
of
my
talk
and
let
me
quickly
do
a
summary
before
we
open
it
up
for
q.
A
first
cargo
is
an
indispensable
tool
for
us
development.
Cargo
is
your
friend.
You
will
use
it
every
single
day.
A
A
There
is
some
roof
for
improvement.
However,
my
most
important
point
of
criticism
here
is
that
it's
rather
hard
to
set
up
a
custom
package
repository.
I
work
a
lot
with
enterprise
customer.
This
is
my
daily
business.
I
earn
money
by
helping
companies
building
great
software
and
many
of
these
companies.
They
have
some
intellectual
property
which
they
don't
want
to
share
with
anybody.
It
could
be
easier
with
cargo
to
set
up
a
custom
package
repository.
A
If
I
compare
that
with
what
I'm
used
to
from
c-sharp
and
javascript,
they
are
all
of
the
major
git
servers.
For
instance,
they
come
up
with
some
out
of
the
box
support
for
for
a
node
package
management
repository
for
a
nougat
repository
and
so
on.
You
have
a
lot
of
great
rig
cloud
services
where
you
just
with
a
click
of
a
button.
You
create
a
private
repository,
and
this
is
unfortunately,
not
that
widespread
in
the
area
of
cargo
and
rust.
A
So
you
have
to
do
a
little
bit
of
tweaking
hand
tweaking
here
or
maybe
select
one
or
two
offerings
which
are
not
that
well
documented
yet,
so
this
is
room
for
improvement,
but
I
hope
that
as
rust
gets
more
more
whites
widely
used.
We
will
find
these
these
improvements
here
with
that.
I
hope
that
you
enjoyed
the
last.
I
don't
know
three
quarter
of
an
hour,
something
like
this.
You
learn
something
new.
A
B
That
a
lot
so
people
are
writing.
People
are
discussing
doing
your
talk.
There
were
a
lot
of
things.
People
have
seen
for
the
first
time,
even
if
they're
long-term
rescue
cargo
users,
especially
the
dock
feature
was,
was
was
very
new
to
to
a
couple.
There
was
one
question
from
from
saiyan.
I
hope
I
pronounced
your
name
right.
B
A
It's
a
static
variable,
it's
a
static
variable
which
is
available
throughout
the
entire
lifetime
of
the
application.
So
what
essentially
lazy
static
is
doing
when
you
enter
this
code
for
the
first
time
it
initializes
this
static
variable
and
when
you
enter
this
code
for
the
second
time
it
will
not
re-initialize
everything
again.
So,
therefore,
if
I,
if
I
reference
this
re
variable
here,
it's
just
a
variable
it
I
get
the
compiled
regular
expression,
which
I
got
when
I
called
is
proper
date
for
the
first
time.
A
Hope
I
I
described
that
good,
just
google
for
static
static
refs
and
you
will
find
more
detailed
information
about
that.
B
As
far
as
you
can
read
it
from
the
chat
it,
it
was
also
saiyan's.
First
guess.