impl
'ementing
by
Felix S. Klock II (@pnkfelix
)
with apologies to
Charles Dickens, David Foster Wallace, and Mark Z. Danielewski
This is a work of fiction. Names, characters, businesses, places, events and incidents are either the products of the author’s imagination or used in a fictitious manner. Any resemblance to actual persons, living or dead, or actual events is purely coincidental.
<manishearth> RIIR!
<pnkscrooge> Bah! Humbug!
Scrooge's optimism about Rust's future had faltered
<pnkscrooge> What’s Rust to you but a language
<pnkscrooge> for writing types without deploying apps;
<pnkscrooge> a language for finding yourself a compile-cycle older,
<pnkscrooge> but not an object file richer?
<pnkscrooge> If I could work my will,
<pnkscrooge> every idiot who goes about with "RIIR" on their lips
<pnkscrooge> should be nailed up in their own crate
<pnkscrooge> and buried with a bicycle gear through their heart
* pnkscrooge was kicked by &manishearth: eeew
and Scrooge was unkind to his comrades as well
<pnkscrooge> Crichit! Cargo is broken!
<acrichto> Are you talking to me?
<pnkscrooge> why invest in adding feature after feature?
<pnkscrooge> forcing people to learn new idioms
<pnkscrooge> they'll just leave and learn Java or C++ instead
<pnkscrooge> change is *death*
* pnkscrooge was kicked by &manishearth: off-topic philosophizing
After Crichit Crichton had gone home, Scrooge pondered over the borrowck error on his screen.
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
10 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error: aborting due to 6 previous errors
Scrooge decided he needed a larger screen to get perspective
--> errmsg.rs:5:9
|
5 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ^
|
= note: #[warn(unused_assignments)] on by default
warning: value assigned to `x` is never read
--> errmsg.rs:6:9
|
6 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ^
warning: value assigned to `x` is never read
--> errmsg.rs:7:9
|
7 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ^
warning: value assigned to `x` is never read
--> errmsg.rs:8:9
|
8 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ^
warning: value assigned to `x` is never read
--> errmsg.rs:9:9
|
9 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ^
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
5 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
...
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
6 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
...
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
7 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
...
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
8 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
...
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
9 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
10 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error[E0597]: `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` does not live long enough
--> errmsg.rs:11:5
|
10 | x = &yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss;
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- borrow occurs here
11 | }
| ^ `yyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss` dropped here while still borrowed
12 | println!("x: {}", x);
13 | }
| - borrowed value needs to live until here
error: aborting due to 6 previous errors
ssyyyhhhhhhhhhhyyyhhhhhddhhhdddddddhhhdddddddddddddhhhhdddddddddddmmmmddmmmmdddddddddddddddddddddddddmmdddddddmmdddhhhyssooooooooooooosssssssyyyyyyyyyyyyyhhhhyys+:-````````````````````````````````````
yyyyhhhhhhhhhhhhhyyyyyhddhhhddddddddhhdddddddddddddddhddddddddddddmmmddddmmddddddddddddddhhhhhhddddddddddddddmmmddhhyyssooooo++++++ooooosssssssyyyyyyyyyyyyyyyyyso/-.```````````````````````````````````
yyhhhhhhhhhhhhhhhyyyyyhddhhhdddhddddddddddddddddddddddddddmdddhhddddddddddddddddddddddhhhhhhhhhhhhdddddddddddddddhyyssoo++++++++++++++ooooooosssssssssssssyyyyyyyo+:..``````````````````````````````````
hhhhhddhhhhhhdhhhyyyyyhhhhhdddhhhdddddddddddddddddddddddddddddhhhdddddddddddddddddddhhhhhhhhhyhhhhhdddddddddddhhhyssso++++++++++++++++++++++ooossssoooooosssyyyyyso/-.``````````````````````````````````
yhhhdddddddddhhyyyyyyyyhhhhddddhddddmddddddddddddddddddddddddddhddddddddddddddddhhhhhhyyyyyyyyyyyhhhdddddhhhhyyyssooo++++++++++/++++++++++++++ooooo++++++oosssyyyyo/:.``````````````````````````````````
yyhhddddddddddhyyyyyyyyhhhddmmdddddmmddddddddddddddddddddddddddhhdddddddddddhhhhhyyyyyssssssssssyyyhhhhhhhyyysssoo++++++++++/////////+++++++++++++////////++ooosyso+:-``````````````````````````````````
yyyhhddddddmddhyyyyyyyyhhdddmmmdddddmddddddddddddddddddddddddddhhhddddddhhhhhhhyyyyyssssoosssssssssyyyyyyysssooo+++++++++++//////////////////////////////////+++oso+/-.`````````````````````````````````
ssyyhhdddddmmddhyyyyyyhhdddmmmmmmdddddddddddddddddddddddddddddhhhhhhhhhhhhhhhhyyyyssssooooooooooooooosssssoooo++++/////++++//////////////////////////////::::/:/++++/-.`````````````````````````````````
ssssyyhhhddddddhyyyyyyhhddddmmmmddddddmdddddddddddddddhdddhhhhhhhhhhhhhhyyhhhyyysssssooooooooooo++++++ooo+++++++++//////++++/////////////////////////////::::::::/+++:...```````````````````````````````
yysssyyhhhhddddhyyyyyyyhdddddmmmddddddmddddddddddddddhhhhhhhhhhhhhhhhyyyyyyyyyyssoooooooooooooo++++++++++++/+++++++//++++///////////////////////////////::::::::::/++:-..`````````...```````````````````
yyyssyyyyyhhdddhhyyyyyyhhddddddddddddddddhhddddddddddhhhhhhhhhyyyyyyyyyyysssssssoooooooooooooo+++++++++++++////+/+++++++++/////////////////////////////////:::::::://:-..```````````````````````````````
yyyssyyyyyhhddhhhyyyyyhhhdddddddddddmddddhhdddddddddhhhhhhhyyyyyyyyyysssssssooooooooooooooooo++++++++++++++///////++++++++/////////////////////////////////::::::::::::-..``````.```````````````````````
yssssyyysyhhhhyhhhhyyyhhdddddddddddddddddhhdddddddddhhhhhyyyyysssssssssssoooooooooooooooooooo++++++++++++++/////++++/+++++////////////////////////////////:::::::::::::-..``````.....```````````````````
sssssyyyssyhhyyyhhhhhhhhhhdddddddddddddddddddddddddhhhhhyyyyysssssssssooooooooooooooooooooooo+++++++++++++++++++++++/+++++///////////////////////////////::::::::::::::-.``````````..```......``````````
ssssssyyyyyyyyyyyyhhhhhyhhhhddddddddddddddddddddddhhhhhhyyyyssssssssooooooooooooo++oooooooooo++++++++++++++++++++++++++++/////////////////////////////////::::::::::::--.`````````...........```````````
sssssssyyyyyyyyysyyhhhhyyhhhddddddddddddddddddddddhhhhhyyyyysssssssooooooooooooooooooooooooooo++++++++++++++++++++++++++////////////////////////////////////:::::::::::-.````..```..````.```````````````
ssssssssyyyssyyyssyyyhhyyhhdddddddddddddddddddddddhhhhyyyyysssssssoooooooooooooooooooooo+ooo+++++++++++++++++++++++++///////////////////////////////////////:::::::::::-..```..`````````````````````````
ssssssosyyysssssssssyyyyhhddddddddddhhddddddddddddhhhhyyyysssssssooooooooooooooooooo+o++++++++++++++++++++++++/+//////////////////////////////////////////////:::::::::--..``..`````````````````````````
ssssssssyyssssssssyyyyyyyhddhhddddddhhdddddddddddddhhhyyyysssssssooooooooooooooooooo+oo++ooooo++++++++++++++++/////////////////////////////////////////////////////:::::---..```````````````...`````````
ssssssssssssssssssyyyyyyyhdhhhddmmdddddddddddddddddhhhhyyyysssssssooooooooooooooooooooooooooooo+++++++++++++++/////////////////////////////////////+////////+++++///////::--..``..```..`````...`````````
oosssssssssssoosssyyyyyyyhhhhhdmmddddddddddddddddddhhhhyyyyssssssssooooooooooooooooooooooo++ooo++++++++++++++//////////////////////////////////+++++++++++++oooooo++++/////:-..`.``...........``````````
+osyyyssssssssssssyyyyyyyhhhhhddddhhdddddddddddddddhhhhyyyssssssssssoooooooooooooooooooooo+++o+++++++++++++++++/++++++//////////+++++++++++++++++++++ooooooossyyyssssooo++++/:-..`....``.......`````````
oosyyysssooosssssssysssyyhhhhhhhhhhddddddddddddddddhhhhyyyssssssoooooooooooooooooooooooooooooo++++++++++++++++++++++++++++++++++++++++++++++++++oooosssssssyyhhhhhhhyyyyyssooo+:.......`````....```...``
oosyyssooooossssossysssyhhhhhhhhhhhddddddddddddddddhhhhyysssssssooooooooooooooooooooooooo+++++++++++++++++++++++++++++++++++++++oooooooooooooooosssyyyyyyyhhhddddhhhdhhhhhyyyyo/-..``....```..``````.```
ooossssooossssssossyssyyhhhhdhhyyyhhhddddddddddddddhhhyyysssssssoooosoooooooooooooooo++++++++++++++++++++++++++++oooo++++ooooooooooooooooooooooossyyyhhhhhddddddddddddddhhhyyys+/:-..-----..-......```..
ooossssooosyysssssssyyyhhhhhhhyyyyyhhhddddddddddddhhhhyyyssssssooooooooooooooooooo+++++++++++++++++++++oooooooosssssssoooossssssssssssssssoooooossyyhhhhdddddddddddhhhhhyyyyyyssoo+++++++ooo+++/:--.``..
oooosssoosyyyysssssyyyyhhyyyyyysyyyhhhhddddddddddhhhhyyssssssooooooooooo+oooooooo++++++ooooo+++++++oooooossssyyyyhhyyyyssssyyyyyyyssssssssssoooossyyhhhhddddddhhhhhyyyyyyysssyyyyyyhhhhyhhhdddhhso/-.```
oooooooossyyyyyyyyyyyyyhhyyyyyssyhhhhhhddddddddddhhyyysssssooooooooo+++++++++o+oooooooooooooooooooosssyyyhhhhhddddddddhhhyyhhhhhyyyssssssssssssosssyhhhhhhhhhhhhhhhhhhyyyyysssssyyyyyhyyyyyhdmmdhy+:.``.
+++oo++osyyyyyyyyyhyysyyhhyyysssyyhhhhdddddddddhhhyyysssoooooooooo+++////++++++ooooooooooooosssyyyyyhhhddddmmmddddddddddhhhhhhhhhyyssssssssooooossyhhhddddhhddhhhhhhhhyyhhysssssyyhhhhhhyssydmmdhyo:.`..
+++ooooossssyyyyhhhhyyyyyyyssssyyhhhyhdddddddhhhhyysssooooooo++++++//////+++oooooosssssssssyyyhhhhhddddddmmmdddddmmdddddddhhhhhyyyssssoooooooooosyyhdddddddddddhhyyyyyhhhhhysso+++ooossssssydmmmhy+:.``.
ooooooossssssyyhhhhhyyyyyyssossyhhhhhhddddddhhhyyysssoooo++++++++///::///++ooooossyyyyyhhhyhhhhddddddddddddddddddddddddddddhhhhyyysssooooooo++osyhhddddddddddddhyssossyhhdhyso/:-----:/ooosydmmdyo:-....
sso++oosssssyyyhhhhyyyyyyssoosyyhhhhhdddmdddhyyysssooo++++++++/////::://++oosssyyyhhhhhhhhhhhddddhhhhdddddddddhhhhhhhhhdddddhhhhhyysssooo++++ooyhhdddddddddhhhhyyso++osyhhhyo/:-....`.-+oooyddhs/-......
ssoooooosssyysyyhhhhhhhhyyssssyhhhhhhddddddhhyyssooo++++++++++//::::://++ossyyyhhdddddddddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdddddddddhyyssoooooosyhhdddddddddddhhhhyyo++osyyyso+/--......:+oooydho:......``
oosssoooossssssyyhhhhhhhhyyyyyhhdddhhddddhhhyyssoo++++++++++++/::://///+osyyhhhdddhhhhhhhhhhhyyhhhhhhhhhhhhhhhddddhhhhhhhhhhhhhddddddhhhhhhhhhdddddddddddddhhhhhyyssssyyyso+/:-.......:+ooosys/.`.......
ssssssooossssssyyhhhhhhhhhhhhhdddddhhhddhhhyyysoo+++++++++++//:::////++osyyhhhhhhhhhhhhhhhhhhhhhhdddddhhyyyyyhhdddhhhhyyyyyyyyhhddddddmmmmmmddddddddhhhhhhhhyyyyyysssssssoo+/:-......-/+ossso+:.`..``...
yyysssssssssyyyyyyhhyyyhhhhhhhhhhhhhyhhhhyyyssoo++///////////////+++oossssyyyhyyyhhhhhdddddddddddddddhhhysssssyyhhhhhhyyyyyyyyhhhddddddmmmddhyyyyhddhhyyyyyyyyssssssssooooo+/:-....-:///+syo/:-.`.`.....
yyyssssssyyhhyysoooooooooooooooosssooossoooo+++///::////++++oooosssssyyysssyyhhdddddddddddddddddddddhhyyysooosssyyyyyyyyyyyyyyyhhhddddddhhysoo+++oshhhyssyyyyyyssssssssoooo+/::--..-:///+syo:..........`
yyyssyyyyyhhhso+/:::::::::::--:::::::::::::://///////++oossssyyhhhhhhhhhyyyyhddddmmmddddddddddddddddddhhys+oossyyyyyyyysssssyyhhhhdddddhysooo++//++oyyyssyyyyyyyysssssssoo++//:-...-:/+osyys/::----.....
sso+++ooossssoooooooo++++++++++++++//////////+++++++ooossyyyyhhddddhhhhhhyyhhddmmmmmmdddddddddddddddddhhysossyyyyyyyyyssssssyyyhhhhddddhysooo+++///++osssssssssssssooooooo+++/:---:/+osyyyssoo++++//////
///////+++oooossyhhhhhhhhhyhhhhhhhyyyyysssssssssssssssyyyyhhhhdddddddhhhhhhhhddmmmmmmmddddddddddddddhhhyyyyyyyyyyyyyyysssssssyyhhhhddddhyssoo++++////++oooooooooooooo++++oooo+++++ossyyyysssssssssoooooo
-::/++oooooooooosyhhddddddddmmmdddddddddddhhhyyyyssssyyyyyyhhhhhhddddddhhhhhhddmmmmmmddddhhhhhhhhhhhhyyyyyyyyyyyyyyyyysssssssyhhhhddddhysssoo+++++//////+oooooooooooooooooooosssssssyyssssssyssssssoosss
//+oossssssssooossyyhhddddddmmmmddddddddddhhhyssooooooooooosssssyyhhddhhhhhhdddmmmmmmddhhhhhhhhyyyyyyysssssssssyyyyysssssssssyyhhhdddhyysssoo+++++//////+oosssssssssyyyyssssso++//+osyyssssyyyysssssssss
oossyyyyyyyyyysssssyyhhhdddddmmmdddddddddhhhhysoo+++++++ooooooossyyyhhhhhhhhhhhddddmdhhhhhyyyyyyyyyysssssssyyyyyyysssssssssssyhhhhhhhysssssoooo++++//////+oossssssssssooooo+++//::/+oyyssssyyyyyssssssss
ssyyyyyyyyyyyyyyyyyyyyyhhhdddddddddddddddhhhyysoo++++++++ooooooossyyyyyyyyhhhhhhhhhddhhhhhhyyyyyyyyyyyyyyyssysssssssssssoosssyhhhhhhyysssssoooo+++++///////+ooooooo+++++++//////:::/ossssssyyyyyssssssss
syyyyysssssssyyyhhyyyyyyhhhddddddmdddddddhhhyssoo+++++++++oo+++oossyyyyyyyyyyyyyyyyhhdhhyyyyyyyyyyyyyyyyyssssssoooooooossssyyyhhhhyyysssoooooooo+++++/////:///+++++++///++///////::/+osssssyyyyyssssssss
ssyyysssooooossyyyyyyyyyyhhhhhhddmmmdddddhhyyssoo+++++++++++++++osssyyyyyyyyyyysssssyhdhyyyyyyyyyyysssssssssssssssssssssyyyyhhyyyyssssoooooooooooo+++++///////////+++/////////////:/+oosssssyyyyysssssss
ssyyyssooo+oooossyyyyyyyyhhhhhhhddmmddddhhhyyssoo+++++++++++++++oosssyssssssyssssssssyhhhhyyysssssssssssssssssssyyyyyhhhhhhhyyyssssooooooooooooooo++++++//////////++++////////////://+osysssyyyyysssssss
ssyyysooooooooossyyhhhhhhhhhhhyhhdddddddhhyyysooo+++++++++++++++ooossssssssssssssssssyyhddhhhhyyyyyyyyyyyyyyyhhhhyyyyyyyyyyyyssssssooooooooooooooo++++++////:::////++////////////:::/+osyyssyyyyyyssssss
ssyyysooooooosssyyhhhhhhhhhhhyyyyhhddddddhhyysooo+++++++++++oooooooosssssssssssssssssssyyhyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssoosossooooooooooo++++++/////:://////////////////:::/oyyyssyyyyyyysssss
ssyyysooooooosssyhhhdddhhhhhhyyyyyhhdmmmddhyyssooo+++++++++oooooooooossssssssssssssssssssssssssssssssssssssooooooooooooooooooossssssssssssoooooooooo+++++++////////////////////////::/oyhyssyyyyyyysssss
ssyyysooooooosssyyyhhhhhhhhhhyyyyyyhddmmmddhyyssoooo+++++++oooooooooooooossssssssssssssooooooooooooooooooooooooooooooooooooooossssssssssssooooooooooo+++++++/////::://++++/////////::/oyhyssyyyyyyyyssss
ssyyysooooooosssyyyyhhhhhhhyyyyyyyyyhddmmddhhhysssooo++++++oooooo++++ooooossssoooooooooooooooooooooooooooooo++++ooooooooooooooossssyssssssssoooooooooo++++++//////:::/+++++//++///////oyhyssyyyyyyysssss
ssyyyysooooooossyysyyyhhhhyyysyyyyyyhhdmmdddhhhyyssooo+oooooooooo++++++ooooooooooooooooooooooooooooo++++++++++++++++++oooooooosssssysssssssoooooooooooo++++++/////:::://++++++++++////oyhyysyyyyyyyyssss
sssyyyysooooooosssssyyhhhyyssssyyyyyyhddmddddhhhyyssooooooooooooo++++++oooooooooooooooo+++++oooo+++++++++++++++++++++ooooooossssssssssssssoooooooooooooo+++++///////::::/++oo+++o+++//oyhyyyyyyyyyyyssss
hhyssyyssooooossssssyyhhhhyysssyyyyyyhddddddddhhhyyssooooooooooooo+++++ooooooooooooo++++++++++++++++++++++++++++++++oooooosssyyysssooooooooooooooooooooo++++/////////:::/+ooo+++ooo+++oyhhyyssyyyyyyysss
ddhsssyyssoooooooossyyhhdhhysssyyyyyyyhddddddddhhyyyssooooooooooooooooooooooooooooooo+++++++++++++++++++++++++++++ooooooossyyyyssoooooooooooooooooooooooo++++///////////++ooo++++ooo++syhhyyssyyyyyyysss
mmdhyysyyysoooooosssyyhdddhyssssyyyyyyhhddddddhhhyyyssssoooooooooooooooooooooooooooooo+++++++++++++++++++++++++ooooooooossyyyyysooooooooooooooooooooooooooo++++++++////+++oooooo+++++osyhhyyyssyyyyyysss
mmmmdhysysssoooooossyyhhhhhyysssyyyyyyyyhhhhhhhhyyyyssssssooooooooooooooooooooooooooooo+++++++++++++++++++ooooooooooooosssyhhyyssooooooooooossssssssssssssoooo++oo+++++++++oooooo++++osyhhyyyssyyyyyysss
NNNNmdhyssssssooooossyyyyyyyyyyhhyyyyyyyyyyyyyyyyysssssssssssoooooooooooooooooooooooooooooooooooooo+oooooooooooooooossssssyhhhyyysssssssosssssyyyyyyyyyyyssssoooooo+++/++++++++ooo++osyyhhyyyyysyyyyssss
NNNNNmdhysssssssooooossssssyyhhdhhhhyyyyyyyyyyyyyyssssssssssssooooooooooooooooooooooooooooooooooooooooooooooooooosssssossssyyyyyyyyyyyyyyyyyyyyyhhhhhhhhyyyyssssooo+++//////+++ooo++osyyhhyyyyyyyyyyssss
mmNNNNmmdyysssssssoosssssooossyhhhhhhhyyyyyyyyyyyysssssssssssssssooosssssssoooooooooooooooooooooooooooooooooooosssssssoossssyyyyyyyyyyhhhyyyyyyhhhhhhhhhhyyyysssooo++//////++++oo++oosyhhyyyyyysyyysssss
mmmNNNNmmdhyssoooooosssssooooossyyyyyhyyyyyyyyyyyyyysssssssssssssssssssssssssssssssooooooooooooooooooosososssssssssossosssssssssssyyyyyyyyyyyyyyyyhhhhhyyyyssssoooo++++///+++++++++osyyyyyyyyyyyyyysssss
mmNNNNNNmmdhyssoooooossssooooooosssyyyyhyyyhyyyyyyyyysssssssssssssssssssssssssssssssssssoooooooooososssyyyyysssssssssssssssssssssssssssssssssssssssssssssssssssyyssssoo+++++++++oooosyyyyyyyhyyyyyysssss
mmNNNNNNmmdhyyyssoooooooooooooooossssyyyyyhhyyyyyyyyyysssssssssssssssssssssyssssssssssssooooossssssososyyyyysssssssssssssssssssssssssssssssssssssssssssssoossssssssssoooo+++++//ooossyyyyyyyhhyyyyysssss
mmmNNNNNmmdhhyyyssssoooooooooooooooossyyyhhyhhhhyyyyyyyssssssssssssssssssyyyyysssssssssssooossssssssssyyyyyyssssssssssssssssssssssssssssssssssssssssssssssoooossssssooooo++++///ooosssyyyyyyhhhyyyssssss
mmmmNNNNmmdhhyyyyyyyyssoooooooooooooossyyhhhhhhhyyyyyyyyssssssssssssssssyyyyyyysssssssssssssssssssssssyyyyyssssssssssssssssssssssssssssssssssssssssssssssoooooooooooooooo++++///+oosssyyyyyyyhhhyyssssss
mmmmmNNNNmddhyyyyhhhhhysssoooooooooooossyhhhhhhhhyyyyyyyyysssssssssssysyyyyyyyyysssssssssssssyysssssssyyyyssssssssssssssssssssssssssssssssssssssssssooooooooooooooooooooo++++///+ossssyyyyyyyhhhyyssssss
mmmmmmNNNNmdhyyyyyhhdddhyysssooooooooossyhdddhhhhhyyyyyyyyysyysssssyyyysyyyyyyyyyyyysssssssssyyssssssssysssssssssssssssssssssssssssssssssssssssssssssssoooooooooooooooooo++++///osssssyyyyyyyhhhhyssssss
ddddmmmNNNmdhhyyyyyhdmmmddhyyysssssssssyhdddddhhhhhyyyyyyyyyyyysyyyyyyyyyyyyyyyyyyyyssssssssyysssssssssssssssssssssssssssssssssssyyyysssssysssssssssssssssoooooooooooooo++++////sssssssyyyyyyhhhhyysssss
dddddmmNNNmmdhyyyssydmNNNmmddhhyyyyyyyhhhdddddhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssyyyssssssssssssosssssssssssssssssssyyyyhyysssssyssooosssssoooooosssssoooooooo+++/////ssssssssyyyyyhhhhyysssss
hddddmmmNNmmddhyyysyhmmNNNNmmddddhhhhhhhdddddddhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssyyyssssssssssosssssssssssssssyyyyyyyyyyhhyssoossso+++oooo+++++++++++++ossssooo++/////yyssssssyyyyyhhhhhyysssy
hhhdddmmNNNmmdhhyysyhdmNNNNNmmmdddddddddddddddddhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssyyysssssssssssssssysssssyyyyhhhhhhhyyyyhyyssoosso++++oooo++////++++///++osssso+++////yyssssssyyyyyhhhhhyyssss
hhhdddmmmNNNmmdhhysyyhdNNNNNNmmdddhddddhhhhhhhdhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssyyyyysssssssssssssyyyyyyyyhhhhhhhhhhyyyyyyyyysssssoooossssoo++++++++/////++ooooo++////yysssssssyyyyhhhhhyyssss
dddddddmmmNNmmddhyyyyhdmNNNNNmmmddhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssyyyyyyyhhhhhhhyyyyyyyyyyyyyyyyyyyyssyyysssssssssooo++////++osoo++///yysssssssyyyyhhhhhhyssss
dddddddmmmNNNmmdhhhyyyhdmNNNNNmmdddhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyysssoossssssssyyyyyyyyyyyssssssssssssssssssssssssssssyysssssssssoo++//+ossso++//yysssssssyyyyhhhhhhyssss
mmddddddmmmNNNmddhhhyyhdmNNMNNNmmddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyysssssssssssssssssssssssssssssssssoooooooooooooooooooooooooossssooo++ossssso+++syssssssssyyyhhhhhhyssss
mmddhhdddmmmNNmmddhhyyhhdmNNNNNmmdddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssooooooooooooooooo+++ooooo+oooooooossssso+++ssssssssssyyyhhhhhhyysss
mmdhhhhddmmmmNNmmddhhhhhdmNNNNNNmmddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssoooooooooooooo++++ooo+++++++++oooooooo+++osssssssssyyyyhhhhhyysss
mmdhhhhhdddmmNNNNmmddhhhhdmNNNNNmmddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssoooosssssssssssssssssssoooooooooossooooooooooo++++++++++++++++++oossssssssyyyyhhhhhyysss
mmddhhhhdddmmmNNNNmmddhhhddmNNNNmmdddhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssososssssssssssssssssssoossssssssssoooooooooo+++++++++/+///+++ossyyssssyyyyyhhhhyysss
mmddhhhhhdddmmmNNNNNmdhhhhhdmNNNmmmdddhhhhhhhhhhhhhhhhhdddhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssssssssssssssssssssssssooooo++++++/////++ossyyysssyyyyyhhhhyysss
mmddddhhhhddmmmNNNNNmddhhhhdmmdddmmddddhhhhhhhhhhhhhhhhhdddhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssssssssssssoossssyyyysssoo+++++++///++/+ossyyysssyyyyyhhhhyysss
dddmmdhhhhdddmmNNNNNmmdhhhhdddysydmmdddhhhhhhhhhhhhhhhhhhhddddhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssssssssssssssssyyyyyyssoo++++++//++++++ossyyysssyyyyyhhhhyysss
dddmmmddddddmmmNNNNNNNmdhhhhhhoosdmmddddhhhhhhhhhhhhhhhhhhdddddddhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssssssssssssssyyhhhyysso++++++//+++oooooossssysssyyyyyhhhyysss
hhdmmmmmddddmmmmNNNNNNmmdhhhhy+/ohmmdddddhhhhhhhhhhhhhhhhhhddddddddhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyysssssssssssssssssssssssssssssssssssssssssosssyyhhhhhyso++++++//+++ooooossssssyssyyyyhhhhyysss
hhddmmmmmdddmmmmNNNNNNNmddhhhy+/ohmmdddddhhhhhhhhhhhhhhhhhhhdddddddddhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssssssssssssssssosssyyhhhhyyso+++++//++oooooooosssyyysssyyyhhhhyssss
hhhddmmmmddmmmmmmNNNNNNmddhhhy+/oydmmmdddhhhhhhhhhhhhhhhhhhhhdddddddddddhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyysssssssssssssssssssssssssssssssssoosssssssssyyyyssooo+++////+oossssoooossssssssyyyyhhhyysss
hhhhdmmmmmmmmmmmmNNNNNNmmddddho+oyhdmmdddhhhhhhhhhhhhhhhhhhhhhhddddddddddddhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyysssssssssssssssssssssssssssssoooooooooooooooooooo++++++++//+ossyyyssssoooooosssyyyhhhyysss
hhhhddmmmmmmmmmmmNNNNNNNmdddmhsooshdddddddhhhhhhhhhhhyyyhhhhhhhhhddddddddddddhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyssssssssssssssssssssssssssoooooooooo+++++++++++++++++++///+ossyyyyyyssooooooosssssssssss
hhhhhdmmmmmmmmmmmmNNNNNNmmddmdysosyhddddddhhhhhhhhhhyyyyyyyyyhhhhhhddddddddddddddhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyysssssssssssssssssssssoooooooooo+++++++++++++++++++///+ossyyyyyyyyyssoooooooooooooooo
hhhhhdmmNNmmmmmmmmmNNNNNNmddddyssoshddddddhhhhhhhhhyyyyyyyyyyyyhhhhhhhddddddddddddddhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyysssssssssssssssssooooooooo++++++++++++++++++++//++syyyyyyyssyyyyysssssssoooo+ooo
ddhhdddmNNmmmmmmmmmmNNNNmmdddhhysoshddddddhhhhhhhhyyyyyyyyyyyyyyyhhhhhhhddddddddddddddhhhhhhhhhhhhhhhhyyyyyyhhyyyyyyyyyyyysssssssssssssssooooooooo++++++++++++++++++++++++syhhhhyyyssssyyyyyyssssssssooo
dddddddmNNmmmmmmmmmmNNNNmddhhhhhysshddddddhhhhhhhhyyyyyyyyyyyyyyyyyyhhhhhhhddddddddddddddddddhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyssssssssssssooooooooooo+++++oo++++++o+++++++oshhhhhhyyyyyssyyhhyyyyyyyyysoo
ddddddmmNNmmmmmmmmmmNNNmmdhhhdddhyyhddddddhhhhhhhhyyyyyyyyysssssyyyyyyyhhhhhhdddddddddddddddddddhhhhhhhhhhhhhhhhhhhhyyyyyyyyyysssssssssssoooooooooooo++++ooo+++++o++ooooosyhhhhhhhhhyyyssyyyyyyyyyyyysoo
ddddddmmmNmmmmmmmmmmNNNmmdhhddddhyyhddddddhhhhhhhhyyyyyyyysssssssssyyyyyyyyhhhhhhddddddddddddddddddddhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyysssssssssoooooooooooooooooooooooooossyyhhhhhhhhhhyyyyyyyyyhhhhyyysoo
ddddddmmmNmmmmmmmmmmmNmmdhhhddddhyyhddddddhhhhhhhyyyyyyyyssssssssssssssyyyyyyyyhhhhhhhddddddddddddddddddddhhhhhhhhhhhhhhhhhhhhyyyyyyyyyssssssssooosooooooooooooooooooossyyyyyhhhhhhhhhhhyyyyyyyhhhhyssoo
ddddddmmmNmmmmmmmmmmmmmmddhhdddhhyyhdddddhhhhhhhhyyyyyyyysssssssssssssssssyyyyyyyhhhhhhhhhhhhhhhdddddddddddddddhdhhhhhhhhhhhhhhhhhyyyyyyyyyssssssssssssssssssssssssssssyyyssyyhhhhhhhhhhhhyyyyyhhhhysooo
mmmdddmmmmmmmmdddddmmmmmmdhhhhhhhyhhdddddhhhhhhhhyyyyyyyyssssssssssssssssssssssyyyyyyyhhhhhhhhhhhhdddddddddddddddddddhhhhhhhhhhhhhhhhhhyyyyyyyyysssssssssssyyssssssyyyyyyyyyyyyyhhhdddhhhhhyyyyyhhyssooo
mmmddddmmmmmmddddddddmmmddhhhhhhhhhdddddhhhhhhhhhyyyyyyyyssssssssssssssssssssssssssyyyyyyyhhhhhhhhhhdddddddddddddddddddddddhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyssssyyyyyyyyyyyyyyhhhdddddhhhyyyyyysooss
mmmddddmmmmmmddhhddddmmmddhhhhhhhhhdddddhhhhhhhyyyyyyyyyysssssssssssssssssssssssssssssyyyyyyyhhhhhhhhhhhhhhhhhhhhhhhhhhhdhhhhhhhhhhhhhhhhhhyyyyhhhyyyyyyyyyyyyyysssssssyyyyhhyyyyyyyhhddddddhhyyyyysssss
mmmdddddmmmmmdhhhhddddmdddhhhhhhhhhdddddhhhhhhhyyyyyyyyyyssssssssssssssssssssssssssssssssyyyyyyyyyyhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyssssssyyyyyyyyyyyyyyyyyyyyyssssyyyyyhhhhyyyhhhddddddhhhyyysssss
mmmdddddmmmmdhhhhhhdddddddhhhhhhhhhdddddhhhhhhyyyyyyyyyyysssssssssssssssssoooooosoosssssssssssyyyyyyyyhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyssssoooooosyyyyyyyyyyyyyyyyyyyyyyysssssyhhhhhhhhyhhhhddddddhyssyyss
<pnkscrooge> its the ghost of nmatsakis!
<nmatsakis> the chains of stability and backwards compat are heavy!
<nmatsakis> you must change your way of thinking
<nmatsakis> tonight you will be visited by three spirits
Niko is not dead
(Well, maybe he is in this story)
(Or at least overwhelmed)
You will be visited by Three Spirits
<epochspast> I am the Ghost of Epochs Past
<pnkscrooge> Long past?
<epochspast> No. Rust's past.
<pnkscrooge> What business brought you here?
<epochspast> Rust's welfare!
Rust 1.0 alpha | 9 January 2015 | |
six weeks later | Rust 1.0 alpha.2 | 20 February 2015 |
six weeks later | Rust 1.0 beta | 3 April 2015 |
six weeks later | Rust 1.0 | 15 May 2015 |
What big changes happened back then?
int
-pocalypseOnce had int
and uint
. It was confusing.
Many renaming initiatives (rust-lang/rust#9940 in 2013, RFC 464 in 2014); all met with resistance
Team almost launched 1.0 with int
/uint
.
Core team learned important lessons about community input and interaction.
After considering many options {imem
/umem
, offset
/size
, intp
/uintp
, ...} finally settled on isize
/usize
we have today.
Rust used to not allow this:
pub struct A<'a, X>(&'a i32, X);
impl<'a, X> Drop for A<'a, X> {
fn drop(&mut self) { println!("dropping A"); }
}
(rustc
did not know/require the &'a i32
be valid while destructor was running)
dropck
rules fixed that, ...
... and, yes, caused some code to start being rejected.
<epochspast> You were once willing to accept breakage
<pnkscrooge> "I was young and foolish then; ...
<pnkscrooge> ... I feel old and foolish now."
The full and true history is probably a 45 minute talk in itself.
catch_panic
Was not possible to recover from a panic on the thread that caused it. (Forced monitor/worker split in separate threads, due to the API's in place.)
Initially landed as catch_panic
in rust-lang/rust/pull/23651.
Later renamed to panic::recover
as part of RFC 1236; but today we know it as ...
panic::catch_unwind
it was finally stabilized in 1.9 release (May 2016); much discussion on rust-lang/rust#27719
mem::forget
is safeRepresented firming up of collective thinking about what unsafe
is meant for.
<epochspast> You see? Rust can change!
<pnkscrooge> That was all madness running up to 1.0.
<pnkscrooge> It proves nothing about where we are now.
<epochspresent> I am the Ghost of Epochs Present
<pnkscrooge> Spirit, conduct me where you will
<pnkscrooge> I went forth last night on compulsion,
<pnkscrooge> and I learnt a lesson which is working now.
<pnkscrooge> if you have aught to teach me, let me profit by it.
Compared to 1.0
IDE support, rustup
, nicer diagnostics (noted by many)
never_type: match x: Result<T, Void> { Ok(_) => ... }
Rc<str>
(RFC 1845)
if let
, ?
-syntax, pub(crate)
, impl Trait
macros 1.1 / Custom Derive / Serde (noted by many)
#[derive]
/// Measure number of heap-allocated values owned by self.
trait Weight {
// default: most values laid inline, not separate `malloc`'ed
fn weight(&self) -> isize { 0 }
}
Some base cases:
impl Weight for i32 { }
impl Weight for i64 { }
// (et cetera)
impl<'a, T: ?Sized> Weight for &'a T { } // someone else owns `T`
impl<'a, T: ?Sized> Weight for &'a mut T { } // not us
// (`?Sized` marker allows things like `str` or `[i32]` as the `T`.)
Heap-allocated things like String
and Box
must be accounted for.
impl Weight for String {
fn weight(&self) -> isize { 1 } // just a single heap allocation
}
Box
has a heap allocation ...
plus its contents may own others!
impl<T: Weight> Weight for Box<T> {
fn weight(&self) -> isize { 1 + (**self).weight() }
}
#[test]
fn test_box_chain() {
assert_eq!( Box::new(Box::new(Box::new("hi"))).weight(), 3 );
}
pub fn breakfast() {
let f = FrenchToast;
assert_eq!(f.weight(), 0);
let p1 = Pancakes { topping: "syrup", atop: None };
Pop quiz: what's p1.weight()
?
assert_eq!(p1.weight(), 0);
let p3 = Pancakes {
topping: "butter",
atop: Some(Box::new(
Pancakes { topping: "berries",
atop: Some(Box::new(
Pancakes { topping: "syrup",
atop: None })) }))};
How about p3.weight()
?
assert_eq!(p3.weight(), 2);
("just count the boxes!")
}
I just lied to you. Code like
let p1 = Pancakes { topping: "syrup", atop: None };
p1.weight()
doesn't work yet; why not?
Likewise, Option<Box<T>>
won't work either.
But we want it to work, like this:
#[test]
fn test_option_box() {
let s: Option<Box<i32>> = Some(Box::new(10));
assert_eq!( s.weight(), 1 );
let n: Option<Box<i32>> = None;
assert_eq!( n.weight(), 0 );
}
("just count the boxes")
impl<T: Weight> Weight for Option<T> {
fn weight(&self) -> isize {
match *self {
Some(ref t) => t.weight(),
None => 0,
}
}
}
(bog standard recursion)
impl<T: Weight, E: Weight> Weight for Result<T, E> {
fn weight(&self) -> isize {
match *self {
Ok(ref t) => t.weight(),
Err(ref e) => e.weight(),
}
}
}
(yadda yadda yadda)
Implementations from previous slide were entirely mechanical, derived directly from structure of Option
and Result
types, respectively.
In fact, one might suggest that a program could generate them for us.
So lets do that
(working from the hypothesis that its easier to transcribe a type definition into a macro invocation...)
use weight_derive::impl_weight_for;
impl_weight_for!(enum Option<T> { Some(T), None });
expands to (after some human adjustment of whitespace):
impl<T> Weight for Option<T> where T: Weight, {
fn weight (&self) -> isize { match *self {
Some(ref x_0) => 0 + x_0.weight(), None => 0, } } }
(Okay, less readable than previous slide. But who cares, its a macro!)
You don't want to see it.
Since you asked
#![feature(proc_macro)]
extern crate proc_macro;
extern crate syn;
#[macro_use] extern crate quote;
use proc_macro::TokenStream;
#[proc_macro_derive(Weight)]
pub fn weight(input: TokenStream) -> TokenStream {
let s = input.to_string();
let ast = syn::parse_derive_input(&s).unwrap();
let gen = impl_weight(&ast);
gen.parse().unwrap()
}
#[proc_macro]
pub fn impl_weight_for(input: TokenStream) -> TokenStream {
let s = input.to_string();
let ast = syn::parse_derive_input(&s).unwrap();
let gen = impl_weight(&ast);
gen.parse().unwrap()
}
fn impl_weight(ast: &syn::DeriveInput) -> quote::Tokens {
let name = &ast.ident;
let weight_body = match ast.body {
syn::Body::Struct(ref variant_data) =>
generate_match_for_cases(
::std::iter::once((&ast.ident, variant_data))),
syn::Body::Enum(ref variants) =>
generate_match_for_cases(
variants.iter().map(|v| &v.ident)
.zip(variants.iter().map(|v| &v.data)))
};
let (impl_params, ty_args, where_clause) = ast.generics.split_for_impl();
let mut added_bounds: quote::Tokens = quote! { };
for bound in ast.generics.ty_params.iter()
.map(|ty_param| &ty_param.ident )
.map(|ident| quote! { #ident: Weight, })
{
added_bounds = quote! { #added_bounds #bound };
}
return quote! {
impl #impl_params Weight for #name #ty_args
where #where_clause #added_bounds {
fn weight(&self) -> isize { #weight_body }
}
};
}
fn generate_match_for_cases<'a, I>(iter: I) -> quote::Tokens
where I: Iterator<Item=(&'a syn::Ident, &'a syn::VariantData)>
{
let mut arms = quote! { };
for (variant_ident, variant_data) in iter {
let (field_names, code) = generate_variant_code(variant_data);
let arm = match *variant_data {
syn::VariantData::Unit =>
quote! { #variant_ident => #code },
syn::VariantData::Struct(..) =>
quote! { #variant_ident { #(ref #field_names),* } => #code },
syn::VariantData::Tuple(..) =>
quote! { #variant_ident(#(ref #field_names),*) => #code },
};
arms = quote! { #arms #arm, }
}
return quote! { match *self { #arms } };
}
fn generate_variant_code(vd: &syn::VariantData) -> (Vec<quote::Tokens>, quote::Tokens)
{
let bind_names: Vec<_> = match *vd {
syn::VariantData::Unit => vec![],
syn::VariantData::Struct(ref fields) => fields.iter()
.map(|f|f.ident.as_ref().unwrap()) // reuse names for struct fields
.map(|i| quote!{ #i })
.collect(),
syn::VariantData::Tuple(ref fields) => fields.iter()
.enumerate() // make fresh names for tuple fields
.map(|(num, _)| { quote::Ident::new(format!("x_{}", num)) })
.map(|i| quote!{ #i })
.collect(),
};
let code = generate_sum_of_var_weights(&bind_names);
(bind_names, code)
}
fn generate_sum_of_var_weights(names: &[quote::Tokens]) -> quote::Tokens {
let mut body = quote! { 0 };
for field_access in names {
body = quote! { #body + #field_access .weight() };
}
return body;
}
(Told you so!)
Procedural macros like impl_weight_for!
are not yet available in the Rust stable channel...
... except for one special case: #[derive]
!
#[derive(Weight)] struct FrenchToast;
yields:
impl Weight for FrenchToast where {
fn weight (&self) -> isize { match *self { FrenchToast => 0, }}}
and
#[derive(Weight)]
struct Pancakes {
topping: &'static str, atop: Option<Box<Pancakes>>,
}
yields:
impl Weight for Pancakes where {
fn weight (&self) -> isize {
match *self {
Pancakes { ref topping, ref atop } =>
0 + topping.weight() + atop.weight(),
}
}
}
derive
is the important special caseWhile it is painful to write out the implementations for standard library types like Option
and Result
, at least the author of a crate providing trait Weight
has the option of doing that work.
But that is useless when it comes to supporting downstream crates of their clients.
That is why support for derive
is so important: It enables crates to to provide a trait and then give clients a zero-cost way to get impl's on their own types.
By implementing Serde's Serialize
and Deserialize
traits (or using derive
to do it automatically), data structures acquire the ability to serialize and deserialize themselves.
The serializaton works with many data formats: JSON, CBOR, YAML, TOML, Pickle (common in Python), BSON (used by MongoDB), URL, et cetera.
They do this via code generated at compile-time; no need for reflection nor runtime type introspection!
In many situations Serde serialization performs at same speed as a handwritten serializer.
derive
isn't special-cased around Serde
; see also e.g. Deisel
crate.
"Small" language additions can enable huge library/ecosystem wins
* epochsyettocome enters the room
<pnkscrooge> ... aren't you going to say something?
* epochsyettocome points
* epochsyettocome points
* epochsyettocome points
* epochsyettocome points
* epochsyettocome points
<pnkscrooge> I can change, and Rust can too!
I am not actually worried about Rust "dying."
Our community is super-charged
and we have "Friends in High Places"
<pnkscrooge> Cratchit, I now see: *life* is change!
<acrichto> ... again, that's not my name.
All recognized that this was a new Scrooge, reformed in his thinking (though not his memory)
Fundamentally different from the man from a year before
One might even call him: a Scrooge for 2018
<aturon> what has pnkscrooge been ranting about?
<aturon> we aren't going to break any code
Already have:
Allow Rust to evolve over time, while keeping old code working
However:
insufficient for some kinds of changes.
allowed changes come at their own pace; Rust evolves gradually and each release is "a somewhat ho hum affair."
Rust project will declare an epoch every two or three years
Each epoch provides
coherent set of new features and APIs, stabilized since last epoch
where tooling, docs and stdlib are updated to mesh with new features
Backwards incompatible changes only available if crate opts into epoch in its Cargo.toml
, e.g.
epoch = "2019"
Otherwise tools assume 2015 epoch.
Rust compilers must support all extant epochs
Crate graph may involve many epochs at once; must be able to link code and preserve semantics.
Each epoch can introduce hard error only if preceding epoch issued a deprecation warning for same input.
catch
(currently implemented as do catch
)
deduce module hierarchy from filesystem
dyn Trait
visibility (crate fn foo
instead of pub(crate) fn foo
)
Note: epochs will largely focus on syntactic changes
None of this can happen without our awesome community!
We're encouraging everyone (at every level of knowledge) to get involved during our 2017 impl
-period. This is the perfect time to dive in and get some mentorship on a bug.
Don't be like Scrooge { epoch = 2015 }
(yes, we know change is hard)
Be like Scrooge { epoch = 2018 }
change can be hard fun
lets get impl
'ing! (but first we fest!)