►
From YouTube: Proc Macro Rules: An overview of procedural macros.
Description
Ariel Hoh gives an overview of Rust procedural macros during a Rust Auckland meet up.
Slides Repository: https://github.com/azriel91/proc_macro_rules
Online presentation: https://gitpitch.com/azriel91/proc_macro_rules/master?grs=github&t=night#/
A
A
Some
live
demos
of
each
of
the
different
procedural
macro
types
as
well
as
learnings
I've
encountered,
while
using
macros
and
an
informative
set
of
slides
again,
okay,
so
macros,
why
would
you
use
macros
so
three
primary
reasons
to
make
code
more
ergonomic
to
write
to
reduce
duplication
when
you're
writing
code
and
reduce
boilerplate?
So
this
is
similar
for
all
kinds
of
languages,
programming
languages.
A
So
in
rust
we
shall
see
how
we
can
increase
economics
using
macros-
and
this
is
just
a
demo-
will
will
actually
go
into
how
it's
done
later
so
make
this
big
and
don't
do
this.
So
when
you're
writing
a
when
we
are
implementing
a
trait
for
a
type
in
rust,
we
tend
to
have
to
impart
the
trait
and
then
write
the
implantation.
So
right
here,
I've
got
a
type
called
health
points,
which
is
a
new
type.
A
New
type
just
means
it's
a
single
tuple
type
over
an
inert
type
and
right
now
the
inner
types
unsigned
32-bit
integer.
So
if
I
want
to
be
able
to
go
health
points
plus
another
health
points,
I
would
have
to
impo.
Add
four
health
points
type.
If
I
need
to
go
a
health
points
plus
equals
another
health
points.
I
need
to
go,
people
add
a
sign
so
and
so
far
for
sub
and
sub
sign.
A
B
A
So
we
shortened
the
amount
of
code
we've
written
and
we've
not
actually
decrease
our
understanding
of
the
concept
it's
quite
organized
and
when
you're
reviewing
code,
if
we
know
that
this
piece
trait
sorry
these
and
derives
are
tested
nicely,
we
know
that
we
don't
have
to
test
the
implementation
of
those
traits
for
every
single
type
that
we
are
implementing
ad
and
the
other
traits
on.
So
that's
one
of
the
benefits.
We
can
reduce
duplication,
so
it's
classes.
A
So
let's
say
we
are,
we
are
really
happy
with
derive
derived
macros
and
we
implement
a
lot
of
them
for
a
particular
strand.
Now,
if
we
have
two
new
types,
one
health
points,
one
skill
points
which
have
very
similar,
meaning
well
similar
structure.
A
So
right
now
I'm
not
importing
the
derive
more
crate
or,
in
my
parting,
beach,
yeah
I'm,
not
importing,
be
derived
macro
in
a
you
statement,
so
I
can
reference
it
directly
in
the
attribute
yeah
yeah.
So
this
is
there's
still
duplication
across
the
multiple
teams
here
and
if
we
want
to
duplicate
that,
we
can
use
another
type
of
procedure.
Macro
called
attribute
macros,
and
this
thing
allows
us
to
do
arbitrary
code
manipulation
with
our
item.
C
A
If
I
write
a
procedure,
America
called
numeric
new
type
and
it
generates
all
of
those
derives.
Then
I
have
again
reduced
the
amount
of
code
that
has
to
be
written
for
multiple
types.
A
This
at
least
for
this
transformation.
You
do
need
to
understand
what
this
macro
does
to
understand
those,
but
so
these
these
are
self-explanatory
and
this
ones
are
not.
So
usually
you
want
to
have
good
Docs
to
link
where
this
comes
from,
okay,
so
the
third
benefit
is
to
reduce
point
of
light.
So
let's
say
I
want
to
write
a
web
application
in
rest.
This
is
all
you
need.
You
need
10
lines.
Well,
you
nee
the
cargo
descriptor
as
well
for
importing
rocket,
but
normally
for
in
setting
up
a
web
application.
A
So
all
of
that
is
hidden
behind
this
procedure.
Emeco
and
conceptually
when
someone's
trying
to
develop
a
web
application,
they
don't
have
to
think
about
all
of
those
log
level
details
and
so
by
using
macros
you
get
to
reuse
all
that
boilerplate
saves
a
lot
of
death
time
cool
so
pretty
fast.
But
now
we
do
need
to
do
that
all
right.
A
So
before
we
going
to
procedural
mackerels
we're
going
to
take
a
look
at
macro
rules,
which
is
the
declarative
macros
that
you
can
write
in
rust,
so
macro
rules
as
a
refresher
and
yet
so
you
have
you
write
a
rule
that
says,
let
me
match
a
pattern
in
this
case.
Nothing
and
let
me
generate
some
other
tokens.
So
in
this
case,
when
someone
calls
a
hello
macro
with
any
of
these
scoped
the
limit
as
the
limiters,
we
will
just
and
print
hello.
So
we
do
that.
A
A
A
So
if
you
Bart,
you
can
do
something
like
have
a
well
try
to
implement
Java
in
rust
and
yeah,
and
so
there's
actually
runs
take
a
rest
yeah.
But
the
thing
with
macro
rules
is
items
that
match
in
patterns.
So
you've
got
rules
here
to
match
certain
patterns.
Your
capture
has
whole
items,
and
so
can
they
cannot
be
broken
down
within
the
macro
body.
A
A
If
I
capture
as
a
block,
I
cannot
actually
pass
it
down
to
another
rule
which
will
deconstruct
that
block
into
separate
tokens,
and
it's
quite
difficult
to
understand
the
error
message
that
comes
out
from
rust.
So
if
we
actually
run
that
we'll
say
it'll
say
no
rules
expected
this
token.
For
this
token,
because
that
token
is
captured
as
a
whole,
whereas
this
rule
is
trying
to
parse
them
as
parts
and
even
though
this
rule
is
correct,
rust
will
not
actually
pass
it
down
and
it
is
really
difficult
to
well.
A
When
you
first
implement
macros,
you
can't
tell
that
this
is
not
actually
being
parsed
by
rust.
It's
it
looks
as
well
from
them
for
me
from
the
error
message.
You
will
intuitively
think
that
oh
I've
got
this
rule
wrong
and
you
spend
ages
trying
to
fix
this
rule.
But
actually
it's
not
your
fault
yeah.
It's
just
the
gap
between
the
error
message
and
what
you
think
it
means.
So
that's
a
lot
of
the
pain
points
of
mecca
rolls
and
so
we're
going
to
look
at
procedural
meckel's.
But
first
does
anyone
have
any
questions
or
comments?
A
None
all
right
so
either
you
understood
that
I
all
did
not
we'll
find
out
all
right,
so
procedural
macros,
so
part
macros
are
macros
defined
with
procedural
code,
which
means
tokens
from
your
source
code
are
parsed
into
an
abstract
syntax
tree.
You
can
write
procedural
code
to
reason
over
that
ast
and
then
generate
output
tokens
and
it's
not
hygienic
by
default.
Who
knows
what
hi
Jeannie
yeah
one
one
I'd
like
to
try
explain
it.
C
Right,
procedural
micro
that
declares
a
variable,
the
compiler
will
take
this
variable
name
compared
against
the
rest
of
your
real
code,
and
it
was
the
same,
give
you
research,
whereas
within
like
a
declarative
macro,
it's
hygienic.
So
if
you
declare
a
variable
with
the
name,
the
Russ
copilot
will
make
that
very
different
from
the
rest
of
the
code,
even
if
it's
the
same
thing.
So
this
avoids
like
conflicts,
that
weird
error
messages.
If
you
have
the
same
variable
name
by
accident,.
A
B
A
So
what
they
look
like
this
three
flavors,
the
first
is
the
function
like
flavor,
which
looks
pretty
much
like
the
declared
macros.
It's
just
your
macro
name,
an
exclamation
mark
and
some
parameters
you
can
do
your
custom
derives
so
you've
seen
the
derive
more
add
earlier
and
you
can
do
custom
attributes.
We
also
briefly
show
that
earlier.
A
So
why
do
we?
Why
should
we
use
proc
macros?
So
for
users
you
get
better
error
messages.
So
when
something
fails,
you
don't
simply
get
no
no
rule
match
for
this
pattern
and
you
can
actually
give
error
messages
such
as
you
specify
this
thing
incorrectly.
Are
we
expected
this
type
to
exist,
so
you
can
do
that.
A
There's
nicer
syntax
when
you're
writing
it
and
for
developers
you're
parsing
an
ast,
an
abstract,
syntax
tree
instead
of
matching
patterns,
so
say:
if
you
have
a
function
with
lifetimes
in
the
declarative
macro,
if
you
need
to
have
those
lifetimes
as
named
tokens,
you
need
to
have
a
different
pattern
for
each
of
those
variants.
If,
in
particular
macros,
you
can
just
pass
the
whole
thing
as
an
item
also
a
function
or
a
struct
or
enum,
and
then,
if
there's
lifetimes,
are
type
parameters
you
can
get
it
out
of
the
exact
same
syntax
tree.
A
You
can
write
procedure
logic,
so
we'll
look
at
this
later,
it's
better
than
not
better
Diagnostics.
So
when
you
do
have
a
mistake
and
you
get
the
rest
compiler
supports
to
see
why
you
you
go
wrong,
it's
easier
to
test.
You
can
write
unit
tests
for
your
procedural
macros
or
integration
tests
and,
oh,
you
need
to
write
your
processing,
your
macros
inside
a
dedicated
crate,
so
you
can't
just
have
like
micro
rules
within
the
same
crate
and
use
it.
That's
really.
Why
is
that?
A
A
So
we're
going
to
look
at
the
function
like
cell
and
that's
anyone
have
any
questions
about
the
concept
so
far.
Okay,
so
if
I,
don't
you
like,
it
looks
like
these
and
so
what
it
does.
It
takes
any
well
farm
tokens
again.
You
have
to
have
matching
brackets
it
outputs
replacement
tokens,
so
everything
within
the
function,
like
micro,
all
of
that
gets
fed
into
the
macro
and
the
micro
determines
why
the
outputs.
So
if
you
want
to
output
nothing,
you
can
do
that.
A
If
you
want
to
output
what
it
got
fed,
then
you
can
do
that
or
you
can
also
output
anything
else.
You
want
so
we'll
look
at
a
demo
for
this.
So
here's
our
function
like
macro
and
yeah.
So
first
one,
let's
make
that
a
little
bit
smaller,
okay,
so
the
one
on
top
is
just
a
function
like
macro
with
a
lot
of
random
target
inside
and
that
corresponds
to
this
procedural
macro
definition.
So
we're
not
actually
going
to
go
through
this
tutorial
style,
I'm
just
going
to
show
you
what
it
can
do.
A
So
if
we
ignore
the
token
stream
completely
and
just
return
say
a
function,
call
hello
returns
a
static
string,
kirara
Pyrus,
that
into
tokens
and
unwrap
again
don't
do
this
and
the
compiler
will
be
happy.
So
if
I
save
this,
what
will
happen
is
this
function,
like
macro
will
turn
into
it's
going
to
turn
into
this.
A
Way
looks
so
it's
going
to
generate
this,
so
if
we
run
this
it's
duplicated,
that's
it
has
to
because
the
top
one
generated
generates
a
as
well,
so
what
to
prove
that
it
exists
and
that's
two
ways.
Well,
we
look
at
one
way
first,
so
we're
going
to
call
the
hello
function
which
we
haven't
declared
in
source
code,
but
this
macro
will
generate
it
and
devalued
I
returned
to
Syrah,
and
if
we
look
at
big
test
for
that
we're
gonna
go
down
here.
A
A
So
if
we
take
away,
it's
gonna
be
happy
again
and
we're
going
to
look
at
another
one,
which
is
a
bit
more
complicated
and
this
one
we're
going
to
see
that
we're
going
to
rename
a
function
to
the
name
that
we
find
inside
its
function
body.
So
we're
going
to
rename
this
function
called
name
into
Tom
and
we're
going
to
rename
of
because
other,
if
I
could
call
name
into
Azrael
and
what
those
functions
will
return
would
be
the
static
string
which
they
each
already
contained.
A
So
Tom
will
return
Tom
as
well
return,
Azrael,
okay,
so
well,
technically,
that
codes
are
written,
so
simply
I
just
have
to
run
it,
and
you
can
see
that
tom
tests
and
Ezra
tests
return.
Okay,
where
we
asserted
that
Tom
returned
tom
and,
as
we
all
returned
to
Azrael.
So
over
here,
I'm
going
to
give
you
a
taste
of
what
it's
like
to
try
and
extract
this
Tom
and
put
into
there.
A
So
you
know
function.
Sorry
in
our
macro
definition
cut
rename
mm-hmm
this
rename
maps.
Do
that
thing
we
want
to
parse
the
stream
of
tokens.
So
what
we
get
in
the
function
line
macro
is
is
actually
this
whole
thing,
which
is
not
current
encode.
This
is
our
stream
of
tokens.
We're
going
to
parse
that
into
an
item
function.
A
Sin
is
a
crate.
You
will
come
across
when
you
are
going
through
the
procedure.
Macro
tutorials,
so
you
just
tell
it
I
want
to
pass
the
tokens
as
an
item
function
and
I
expected
to
pass
successfully
if
it.
If
someone
gave
us
something
other
than
a
function,
then
we
will
get
there
and
in
order
to
reach
that
Tom,
so
there's
many
many
layers
I'm
going
to
expand
this
side
of
Alomar.
A
So
item
function
is
our
whole
function
and
we're
going
to
look
for
the
block,
which
is
that
luck
here
and
within
the
block
that
can
be
multiple
statements,
its
so-called
statements,
and
actually
wanted
to
show
you
this
traverses
through
here.
So
yes,
that's
here's
the
dots
for
sin.
What
will
happen?
What
will
happen
when
you
are
writing
a
pragmatic
Oh?
Is
you?
What
is
you
will
traverse
the
whole
tree
and
open
many,
many
many
tabs?
So
so
you
feel
item
function.
A
A
Be
a
field
or
deconstructing
a
time
you
go
into
statements.
Each
statement
can
be
one
of
many
types
of
statements.
This
is
kind
of
like
looking
at
the
structure
of
how
it
is
and
looking
at
the
structure
of
how
RUS
abstract
syntax
tree
looks
like
the
statement
we
are
going
to
use
and
be
the
dogs
are
really
good
for
determining
what
we
want.
A
We
know
that
we
are
looking
for
a
static
string,
so
that's
going
to
be
a
expression
without
trying
semicolon,
so
we
go
into
that
and
at
the
same
time,
I'm
going
to
flick
back
to
here
to
show
you
that
hey,
we
went
to
your
item
function.
You've
your
blocks,
your
statements,
it
was
a
vector,
so
we
call
first,
we
expect
we're
nothing
in
your
handing
here.
So
we
expect
we're
going
to
grab
that
one
statement
out.
A
Then
we
are
going
to
deconstruct
it.
So
this
syntax
is
a
bit
foreign.
If
you
haven't
come
across
rest
for
very
long,
what
you
can
do
is
you
can
go
if
let
and
then
you
can
pass
in
many
many
types
to
deconstruct
an
object
into
its
lower
fields
such
that
you
can
reference
one
of
the
lower
lower
fields,
well,
one
of
the
fields
in
deepen
hierarchy.
A
So
what
you
don't
have
to
do
is
like
in
Java,
you
would
probably
go
call
object
that
gets
feel
that
get
subfield
I
get
another
feel
so
you
so
in
rest.
You
don't
have
to
call
methods
on
that.
You
can
construct
the
type
directly,
so
M
will
be
traversing
like
statement
looking
for
an
illiterate
expression
and
looking
for
a
string
literal
and
then
getting
that
value
of
that
string
so
see
very
far.
A
Okay,
so
M.
What
we
do
with
that
a
value
is
we'll
just
replace
the
function
name
and
and
write
that
out.
So
when
we
write
it
out,
we
need
to
convert
from
our
type.
So
what
we
get
here
is
an
item
function,
which
is
a
strong
type.
We
need
to
turn
that
into
taupe
and
set
the
rest.
Compiler
can
parse
and
compile
into
your
source
code.
So
we
do
two
things.
A
Well,
we
we
use
a
crate
called
quote,
which
turns
your
sin:
data
types
into
a
token
stream
of
a
different
type
to
Russ
token
stream,
and
this
reason
for
that
we
won't
go
into
that
I
believe
today
and-
and
you
can
turn
that
special
token
stream
into
rust
version
of
the
token
stream
so
M
and
there
you
have
it
that's
pretty
fast.
But
if
you
have
any
questions
actually
do
you
doesn't
have
any
questions
right
now,
yep.
B
A
So
I've
got
it
and
if
net,
so,
if
that
means
we're
going
to,
if
it
matches
this
D
structure,
Eirene
pattern,
otherwise
it
will
panic.
So
yeah
nice
thing
about
this
destructuring,
or
rather
parsing,
is
if
your
item
function
is
not
just
a
simple
function,
but
it's
actually
a
function
with
many
thing,
so
you've
got
a
type
parameter.
It's
got
a
trait
bound.
We,
this
code
will
still
happily
work
because
sin
is
clever
enough
to
parse
all
of
those
into
the
abstract
syntax
tree
and
it's
different
Rita
as
a
function.
A
B
A
Also,
yes,
and
the
weight
depends
like
you're
doing
I,
don't
think
what
macros
can
access
comments,
but
there
is
the
rest
own
syntax
recompilation,
which
can
yeah.
So
Russ
is
own
syntax
compilation
greatest
called
lip
syntax
and
if
you
are
writing
something
like
Russ
formats
okapi
and
you
need
to
read
that
information
and
you
want
to
go
to
that
level,
which
is
one
level
deeper,
yeah.
A
A
Because
I
get
we've
been
through
that
be
there.
Yes,
questions
any
more
questions
before
I
go
no
okay,
good!
All
right!
So
do
you
write
macros?
So
it
looks
like
this.
You've
got
yard
arrived
because
I'm
your
eyes
and
you
can
actually
from
rust,
I
think
1:30
I
may
be
wrong.
You
can
have
your
path
to
your
custom
me
right,
so
path
being
the
crate
name
that
provides
custom,
derive
and
derived.
A
Yeah
so,
for
example,
it
was
the
derive
more
add,
was
housing
the
ads
in
trade
niblet
a
Shinto,
my
health
points.
Are
there
okay?
So
so
what
do
you
write?
Franco,
so
yeah
attach
to
a
struct
or
an
enum?
You
can
only
do
this
with
your
own
type,
so
you
can't
do
it.
You
can
either
derive
to
say
type
melius.
A
A
You
can
have
helper
attributes,
which
means
I.
Think
I
have
one
example
later
on
we'll
sure,
whatever
that
and
you
cannot
see
the
derive
meta
item,
which
is
another
way
of
saying
if
you
have
code.
So
if
you
have
a
custom
derive
which
looks
at
this
type,
what
you
actually
get
is
you
you
do
get
the
comment.
Well,
if
it's
slash,
you
will
get
the
doc
attributes
and
passed
into
your
token
stream
as
well.
A
A
This
custom
derive
can
declare
that
I
want
to
have
special
attributes
which
can
give
me
additional
parameters
to
how
I
implement
my
arrived.
That's
probably
better
seen
than
heard
so
we'll
look
at
that
really
soon.
So,
what's
urk.
So
what
the
token
stream
that
the
custom
derived
will
see
is
this
so
documentation
for
our
struct
is
seen
as
an
attribute.
A
So
it's
a
it's
a
meta
attribute
to
the
struct,
even
if
it
is
written
on
top,
has
a
triple
slash
that
is
passed
as
a
part
of
the
token
stream
to
your
custom
derive
implementation,
and
you
can
see
other
people's
attributes
on
your
struct,
but
you
cannot
see
the
derive
attribute.
So
that
means,
if
you
want
a
custom,
derive
to
say
if
this
struct
derives
clone
as
well,
do
something
else.
You
cannot
do
that.
A
You
could
in
I
think
earlier
versions
of
the
product
microamps
apart,
but
if
we
remove
that
so
and
we
will
actually
look
at
with
the
lifetime
only
just
after
this,
so
what
you
can
do,
you
can
generate
input
box,
so
the
rice
add,
will
let
you
import
add
for
your
type.
You
can
join
more
types,
so
if
you
say
I
want
to
for
the
rightful
generate
a
struct
called
foo
bar,
you
can
do
that
as
well,
and
what
you
cannot
do
is
mutate,
the
type
at
least
not
with
derived
macros.
A
A
A
A
New
which
returns
self
self
is
an
alias
and
that
russ
has
for
each
type
when
you're
entering
the
type
implementing
a
time-
and
it's
just
great
can
return
a
new
version,
a
new,
a
new
instance
of
itself,
and
you
can
see
here,
I'm
adding
my
own
documentation
string.
So
you
can
see
that
this
compels
nicely.
I
can
prove
that
it
does
not.
If
I
do
this,
so
my
struck
new
doesn't
exist
until
I
am
derive.
New
and
I
can
call
it,
and
what
this
will
generate.
I
think
I
think
it
doesn't
generate
too
much.
A
So
we
can
do
this.
So
cargo
expand
is
a
really
useful
tool
to
see
what
tokens
are
generated
when
you
are
writing
parse
it
your
macros
and
Akiane
macros.
So,
if
your,
if
your
macro
generates
syntactically
complete
tokens,
it
will
output
those
tokens
otherwise
you're
on
your
own,
because
it
will.
If
you
have
broken
tokens,
it
will
just
say
it's
broken
and
you
don't
get
any
outfit
at
all.
A
A
Okay,
so
so
Carr
Gomm,
corrects
mind
is
really
nice
for
figuring
out
what
your
macros
actually
producing.
Okay,
so
see
semifinals,
we
will
do.
A
A
Scheffer,
okay,
I
do
not
get
an
example
of
a
fubar
yeah,
unfortunately,
okay,
well,
gosh,
look
at
show,
attributes
so
show.
Attributes
is
a
derive
that
will
show
us
what
attributes
a
proc
macro
can
see,
and
it's
got
a
show
attribute
helper
attribute
and
what
that
means
is
when
I
derive
show
attribute.
I
can
also
have
this
show
a
true
as
an
attribute
and
I
will
pass
a
parameter
to
tell
me
what
what's
the
value
of
the
parameter
attribute.
A
And
run
that
here,
so
this
will
show
us
that
for
a
destructive
attributes,
which
is
this
struct,
we'll
look
at
the
dark
attribute,
which
is
all
of
these
and
the
implement
the
implementation
of
this
will
just
return
a
sorry.
It
will
generate
a
function,
call
attribute
list
which
returns
a
vector
of
the
attribute
list.
A
A
No,
has
anyone
got
questions
about
this.
B
B
A
B
A
A
B
A
A
Okay,
so
attribute
macros
so
attribute.
Macros
are
the
more
powerful
form
of
say,
Iraq
makers
there's
actually
a
bit
there
that
she
may
be
somewhere
between
function
like
and
the
Iraq
macros.
So
what
they
look
like
is
look
at
what
they
look
like.
So
it's
this
thing,
so
the
attribute
macros
I'm,
taking
a
syntax
tree
and
outputs
replacement
tokens.
So
what
that
means
is
whatever
you
take
in.
You
can
decide
to
remove
it
completely
or
you
can
decide
to
just
put
it
as
is
or
you
can
do
other
transformations
so
yeah
it
does
I.
A
A
This
new,
this
numeric
new
time
macro,
is
a
macro
for
them
to
derive
all
of
these
derivations
on
new
types
on
numeric
new
types,
and
then
you
sat
in
my
game,
so
health
points
and
I
have
something
else
called
a
weight
which
is
just
a
lot
thicker,
but
we'll
actually
see
what
the
use
of
a
know
up,
as
well
as
a
blank
remove
attribute
macros.
So
for
that
one
it's
got
the
next
step.
A
So
for
our
know,
up
macro
we
take
in
a
token
stream
off
an
item
and
we
just
we
can
do
item
so
it
looks
like
I'm
doing
a
know
up
and
I
am,
but
there
is
some
use
to
that.
So
if
we
look
here,
we've
got
no
ops
on
all
of
these
things,
as
well
as
some
commented
out,
no
ops
what
happens?
A
Well,
we
nice
to
say
that
nothing
happens,
but
if
I
uncomment
this
they
know
up
macro
will
actually
cause
rust,
compiler
to
also
check
yes,
the
attribute
is
the
attributes
applying
to
something
that
it
should
be
applied
to
with.
Why
is
it
not
going
to
the
end
and
all
right
for
some
reason
and
goes
to
home
of
the
previous
line,
but
we
can
trigger
compiler
errors
with
attributes.
A
So
that's
that's
one
use
of
no
op
attribute
another
use
is
similar.
I
think
it's
this
one.
We
can
get
actual
invalid
rust,
so
rust
doesn't
want
to
parse
this
in
the
syntax
tree
where,
whereas
over
here,
it
just
possible,
but
it's
just
experimental.
So
that's
what
you
can
use
is
that
you
get
far
but
no
real
practical
use.
A
Okay,
so
the
other
one
they
remove
the
remove
attributes.
Well,
I,
guess
return.
You
know
tokens
for
anything,
you
tagged
or
remove
on
to
so
over
here,
and
you
can
see
that
if
this
struct
is
private
and
I
tagged,
every
move
rust
doesn't
warn
me
with
any
warnings.
But
if
I
come
in
out
the
remove
attributes,
it's
going
to
complain,
saying
hey:
this
struct
is
never
constructed.
A
A
Okay
and
there's
one
thing:
I
do
want
to
show
you
about
attribute
macros,
where
you
have
to
be
careful,
so
the
numeric
new
type
macro
and
I
showed
you
earlier.
So
what
that
does
is
on
the
health
points
object
when
I
attack
it
with
numeric
new
type.
It's
going
to
give
me
these
your
eyes
and
the
thing
is
you
have
to
handle
the
cases
where
there
are
existing
drives
on
the
health
points
type,
and
earlier
we
saw
with
the
derive
mode
macro.
A
We
could
not
see
the
drive
attribute,
but
with
the
attribute
macro
we
can't
and
therefore
we
can
say
all
right-
we're
going
to
parse.
This
attribute
look
at
the
existing
values
and
do
some
intersection
with
that.
So
we
can
tell
whether
the
user
has
already
specified
some
of
the
give
arise
that
we
want
to
add
or
has
not,
and
we
can
do
some
error
handling
based
on
that.
So
just
a
quick
demonstration,
if
I
add
the
add
macro,
which
is
already
added
by
the
attribute
macro
I,
will
get
a.
A
Warning
come
on
RR
and
error,
eventually
Oh
compile,
while
it
does
well
it
does.
Let
me
show
you
the
code
for
that
so
inside
the
proc
micro
attribute
definition
we're
going
to
look
at
the
types
attributes
and
inside
there
we're
going
to
so
here
we
first
list
the
derives
that
we
want
to
add
to
the
type.
A
A
When
you
find
the
existing
gear
eyes
we're
going
to
intersect
that
with
the
derive
list
that
we
want
to
add
to
that
type,
we
find
find
anything
that
exists
if
there
are
any
intersecting
type.
So
it's
not
empty,
then
we're
going
to
give
the
user
warning
and
we
give
them
an
error
message
which
they
can
reason
over.
So
if
we
look
at
the
error
message,
it's
going
to
say
hey.
These
are
all
already
automatically
derived
when
the
numeric
new
type
as
we
get
is
used,
and
we
tell
them
we
tell
them
add
so.
A
This
is
all
in
the
panic
message.
Right
now.
Rest
does
not
have
support
to
actually
undertake
the
source
code
with
here's,
the
actual
token,
where
the
error
occurs,
so
that
doesn't
open
ticket.
So
this
is
much
nicer
than
say
if
you
use
well,
if
you
try
to
use
a
declarative
macro,
it's
going
to
be
really
really
difficult
to
actually
handle
like
multiple
derives.
A
A
Information
dense,
alright,
okay,
let's
see
three
their
currents
breathing
all
right,
so
part
Marcos.
How
so
we
got
a
few
minute
stuff.
So
that's
the
blog
post
elects
Crichton
wrote
this
enough
last
year.
It's
a
really
good
start
to
write,
think
our
micros
and
that's
the
reference
book.
It's
also
really
good.
I
use
this
actually
use
it
to
write
this
presentation,
all
right
and
crazy.
I
encounter
sin
quote
micro,
which
is
this
one's
actually
from
the
Senate
Library
and
the
other
three
are
not
and
there's
a
summary
of
what
each
crate
is
yeah.
A
We
don't
have
time
to
go
through
this,
but
have
a
read
and
you'll
probably
figure
it
out
a
lot
more
when
you
actually
play
with
proper
macros.
Okay,
so
I'm
learnings
use
qualified
type
names
when
referring
to
a
known
type
of
trait
so
ahead.
So
if
you're
going
to
return
it,
if
you're
the
generate
code
that
returns
a
result,
it
is
good
to
qualify
that
tightening
cuz
result
is
easily
overloaded
with
different
namespaces.
A
But
that
means,
if
your
trait
actually
comes
from,
say
specs
we
don't
need
to
the
consumer
does
not
have
to
import
specs
India
cargo
descriptor.
You
can
just
reuse
the
re-exported
crate
from
say
amethyst,
yep,
I'm
missing
contacts
for
you
guys
but
yeah,
sorry,
so
M!
If
you
do
use
the
qualified
name,
then
what
the
user
has
to
do
is
to
to
import
both
amethyst
and
specs,
or
important,
amethyst
and
rename
the
usage.
A
It's
not
very
ergonomic,
so
non
qualified
names
there's
use
cases
for
that,
but
it's
really
depending
on
whether
your
repository
is
going
to
be
used
by
multiple
people
or
you
control
the
whole
project,
and
you
know
the
path
for
sure
alright
learnings,
so
a
bit
more
prefix.
So
if
you
have
attribute
helpers
for
a
custom,
V
right
prefix,
those
attributes
fix
those
help
attributes
with
your
crate
name,
to
avoid
collision.
So
these
certainly
struck
top
and
SRAM.
A
Macros
are
all
looks
okay,
so
nice,
wrapped
up
and
Jericho's,
are
all
crates
that
provide
procedural,
macros
and
part.
My
go
derives
specifically,
and
they
all
have
this
way
of
renaming
how
they
see
realize
things.
So,
unfortunately,
we
have
one
inconsistency,
but
oh
yeah.
We
try
to
keep
the
attribute
parameters
the
same
across
different
crates
in
the
ecosystem,
so
yeah
you've
got
renamed
all's
here
as
Lysol
and
renamed
all,
but
you
can
tell
which
create
derive
that
you
are
passing
that
parameter
to
okay,
learning's
yep,
kara
expands
helps
a
lot.
A
You
saw
the
excited
tokens
earlier
and
if
you
output,
none
well
from
tokens
such
as
a
broken
brace,
then
cargo
expand
does
not
help
a
lot
alright
and
if
you
need
help,
the
community
discard
server
is
pretty
good.
The
MCOs
channel
has
a
lot
of
people
who
will
help
you
pretty
quickly
when
you
ask
and
a
little
summary
okay
summaries
a
bit
later.
A
So
am
you
can't
parse
paths
in
attributes
so
right
now,
Russ
allows
you
to
specify
crate
name:
colon
double
colon
rock,
my
rock
record
derive
name,
but
you
cannot
pass
that
with
sin.
You
can
write
your
problem.
Echo
derive
Wilson,
but
you
cannot
pass
this
with
its
in
point
point
one
five
and
that
will
come
out
in
the
soil.
Sorry
support
for
this
will
come
out
in
the
next
version
of
sin.
We
don't
know
when,
though,
this
output
morning
to
span
information,
so
actually
undertake
the
code
where
your
error
happens.
A
A
A
Do
most
developers
and
rice
and
so
I
think
most
developers
would
first
check
crates.
Io+
am
a
lot
of
useful
macros
are
already
written
there
for
myself.
I've
only
had
to
write
them,
say
two
or
three
times
because
I
most
of
the
other
things
I
want
to
do
are
like
parsing
there
all
the
vodka
libraries
and
adding
more
drives.