ãã®èšäºã¯Lin ClarkeãRustéçºããŒã ãšå
±åã§äœæããŸããïŒæ¬æã§ã¯ãç§ãã¡ãïŒã Rustã®å
¬åŒããã°ã§
æçš¿ãèªãããšãã§ããŸãã
Rust 2018ã®æåã®ããŒãžã§ã³ã¯2018幎12æ6æ¥ã«ãªãªãŒã¹ãããŸããããã®ãªãªãŒã¹ã§ã¯ãRustã®éçºè
ãå¯èœãªéãå¹ççã«äœæ¥ãéå§ã§ããããã«çç£æ§ã«çŠç¹ãåœãŠãŸããã
ã¿ã€ã ã©ã€ã³ã¯ãããŒã¿ããRust 2018ããã³Rust 2015ãžã®ç§»è¡ã瀺ããŠããŸããããŒã«ã®ã¢ã€ã³ã³ãš4ã€ã®é åïŒWebAssemblyãçµã¿èŸŒã¿ããããã¯ãŒã¯ãCLIïŒã«å²ãŸããŠããŸãã èµ€ãäžž-éçºè
ã®çç£æ§-ã¯Rust 2015ãé€ããã¹ãŠãå²ãã§ããŸãããããäžè¬çã«Rust 2018ãäœã§ãããã説æããã®ã¯ç°¡åã§ã¯ãããŸããã
äžéšã®äººã¯ããããèšèªã®æ°ããããŒãžã§ã³ãšããŠæ瀺ããŠããŸã...ãã®ãããªãã®ã§ãããå®éã«ã¯ããã§ã¯ãããŸããã ããã§ãæ°ããããŒãžã§ã³ããšã¯ãä»ã®èšèªã®æ°ããããŒãžã§ã³ãæå³ãããã®ã§ã¯ãªãããããå®éã«ã¯ãªãããšèšããŸãã
ä»ã®ã»ãšãã©ã®èšèªã§ã¯ããã¹ãŠã®æ°æ©èœã«ããæ°ããããŒãžã§ã³ãè¿œå ãããŸãã åã®ããŒãžã§ã³ã¯æŽæ°ãããŸããã
Rustã·ã¹ãã ã®åäœã¯ç°ãªããŸãã ããã¯ãèšèªã®éçºæ¹æ³ã«ãããã®ã§ãã ã»ãšãã©ãã¹ãŠã®æ°æ©èœã¯ãRustãš100ïŒ
äºææ§ããããŸãã å€æŽã¯å¿
èŠãããŸããã ããã¯ãRust 2018ã³ãŒãã«éå®ããçç±ããªãããšãæå³ããŸããã³ã³ãã€ã©ã®æ°ããããŒãžã§ã³ã¯ãããã©ã«ãã§ãRust 2015ã¢ãŒãããåŒãç¶ããµããŒãããŸãã
ããããèšèªã®éçºã«ã¯ãæ°ããæ§æãªã©ã®é©æ°ãå¿
èŠã«ãªãå ŽåããããŸãã ãããŠããã®æ°ããæ§æã¯æ¢åã®ã³ãŒãããŒã¹ãç Žå£ããå¯èœæ§ããããŸãã
ããšãã°ã
async/await
é¢æ°ã åœåãRustã«ã¯ãã®ãããªæŠå¿µã¯ãããŸããã§ããã ãããããããã®ããªããã£ãã¯æ¬åœã«æçšã§ãããéåæã³ãŒãã®èšè¿°ãç°¡çŽ åããããšãããããŸããã
ãã®æ©èœã§ã¯ã
async
ããã³
await
ããŒã¯ãŒããè¿œå ããå¿
èŠããããŸãã ãã ãã
async
ãŸãã¯
await
ãå€æ°åãšããŠäœ¿çšã§ããå€ãã³ãŒããå£ããªãããã«æ³šæããå¿
èŠããããŸãã
ãããã£ãŠãRust 2018ã«ããŒã¯ãŒããè¿œå ããŸããæ©èœã¯ãŸã ãªãªãŒã¹ãããŠããŸããããããŒã¯ãŒãã¯çŸåšäºçŽãããŠããŸãã ä»åŸ3幎éã®éçºã«ãããäºææ§ã®ãªãå€æŽïŒããšãã°ãæ°ããããŒã¯ãŒãã®è¿œå ïŒã¯ãã¹ãŠãRust 1.31ã§äžåºŠã«è¡ãããŸãã
Rust 2018ã«ã¯äºææ§ã®ãªãå€æŽããããŸãããããã¯ã³ãŒããç Žæãããšããæå³ã§ã¯ãããŸããã
async
ããã³
await
å€æ°ã䜿çšããŠããã³ãŒãã¯ã³ã³ãã€ã«ãããŸãã ããã©ã«ãã§ã¯ãã³ã³ãã€ã©ã¯ä»¥åãšåæ§ã«åäœããŸãã
ãã ããæ°ããé¢æ°ã®ããããã䜿çšããå Žåã¯ãRust 2018ã®æ°ããã³ã³ãã€ã«ã¢ãŒããéžæã§ããŸãã
cargo fix
ã³ãã³ãã¯ãæ°ããé¢æ°ã䜿çšããããã«ã³ãŒããæŽæ°ããå€æŽãè¡ãããã»ã¹ãèªååããå¿
èŠããããã©ãããéç¥ããŸãã ãã®åŸãæ°ããé¢æ°ã®äœ¿çšã«åæããå Žåã¯ã
edition=2018
ãCargo.tomlã«è¿œå ã§ããŸãã
Cargo.tomlã®ãã®ããŒãžã§ã³æå®åã¯ããããžã§ã¯ãå
šäœã«ã¯é©çšããããäŸåé¢ä¿ã«ãé©çšãããŸããã ç¹å®ã®1ã€ã®ã©ãã¯ã«å¶éãããŸãã ã€ãŸããRust 2015ãšRust 2018ã®ã¯ã¬ãŒããåæã«äœ¿çšã§ããŸãã
ãããã£ãŠãRust 2018ã䜿çšããŠãããã¹ãŠãRust 2015ãšã»ãŒåãã«èŠããŸããã»ãšãã©ã®å€æŽã¯Rust 2018ãšRust 2015ã§åæã«å®è£
ãããŸããäºææ§ã®ãªãå€æŽãå¿
èŠãªæ©èœã¯ãããããã§ãã
Rust 2018ã¯ãäž»èŠèšèªã®å€æŽã ãã§ã¯ãããŸããã 圌ãã ãã§ã¯ãããŸããã
Rust 2018ã¯ã第äžã«ãäž»ã«èšèªå€ã®ããŒã«ã®ãããã§ããŸãç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ã®éçºãšãRustããããã®ã±ãŒã¹ã§æãå¹æçãªããã°ã©ãã³ã°èšèªã«ããæ¹æ³ã®ç解ã®ãããã§ãRustéçºè
ã®çç£æ§ãæ¹åããããã®æšé²åã§ãã
ãããã£ãŠãRust 2018ãCargo.tomlã®æå®åãšããŠè¡šãããšãã§ããŸããããã¯ãäºææ§ã®ãªãå€æŽãå¿
èŠãšããããã€ãã®é¢æ°ãå«ããããã«äœ¿çšãããŸã...
ãããã¯ãããã©ãŒãã³ã¹ããªãœãŒã¹ã®å¹ççãªäœ¿çšããŸãã¯é«ãä¿¡é Œæ§ãå¿
èŠãªãšãã«ãRustãå€ãã®ã¢ããªã±ãŒã·ã§ã³ã«ãšã£ãŠæãå¹ççãªèšèªã®1ã€ã«ãªã£ãŠããæç¹ã§æ³åã§ããŸãã
å®çŸ©ã®2çªç®ã®ããŒãžã§ã³ããå§ãããŸãã ããã§ã¯ãèšèªå€ã§è¡ããããã¹ãŠã®æ¹åç¹ãèŠãŠãããèšèªèªäœã«é£ã³èŸŒãã§ã¿ãŸãããã
ç¹å®ã®çšéã®é
ããã°ã©ãã³ã°èšèªã¯ãæœè±¡çã«ã¯å¹æçã§ã¯ãããŸããã ç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ã§å¹æçã§ãã ãããã£ãŠãRustãèšèªãŸãã¯ããŒã«ãšããŠæ¹åããããšã ããå¿
èŠã§ã¯ãªãããšãç解ããŸããã ãŸããç¹å®ã®é åã§ã®Rustã®äœ¿çšãç°¡çŽ åããå¿
èŠããããŸãã
å Žåã«ãã£ãŠã¯ãããã¯ãŸã£ããæ°ãããšã³ã·ã¹ãã çšã®ãŸã£ããæ°ããããŒã«ã»ãããäœæããããšãæå³ããŸããã ä»ã®å Žåã§ã¯ãæ¢åã®æ©èœãšåªããããã¥ã¡ã³ãã磚ããŠã皌åäžã®ã·ã¹ãã ãç°¡åã«èµ·åããã³å®è¡ã§ããããã«ããŸãã
RustéçºããŒã ã¯ã4ã€ã®åéã§ã¯ãŒãã³ã°ã°ã«ãŒãã圢æããŠããŸãã
- Webassssembly
- çµã¿èŸŒã¿ã¢ããªã±ãŒã·ã§ã³
- ãããã¯ãŒã¯ã¿ã¹ã¯
- ã³ãã³ãã©ã€ã³ããŒã«
Webassssembly
WebAssemblyã¯ããŸã£ããæ°ããããŒã«ã»ãããäœæããå¿
èŠããããŸããã
WebAssemblyãRustãªã©ã®èšèªãã³ã³ãã€ã«ããŠã€ã³ã¿ãŒãããäžã§å®è¡ã§ããããã«ããã®ã¯æšå¹Žã ãã§ãã ãã以æ¥ãRustã¯ããã«æ¢åã®Webã¢ããªã±ãŒã·ã§ã³ãšã®çµ±åã«æé©ãªèšèªã«ãªããŸããã
Rustã¯ã次ã®2ã€ã®çç±ã§Webéçºã«é©ããŠããŸãã
- 貚ç©ç®±ãšã³ã·ã¹ãã ã¯ãã»ãšãã©ã®Webã¢ããªã±ãŒã·ã§ã³éçºè
ãæ
£ããŠããæ¹æ³ã§æ©èœããŸãã å€æ°ã®å°ããªã¢ãžã¥ãŒã«ãçµã¿åãããŠããã倧ããªã¢ããªã±ãŒã·ã§ã³ãäœæããŸãã ã€ãŸããRustã¯å¿
èŠãªå Žæã§ç°¡åã«äœ¿çšã§ããŸãã
- Rustã¯ãªãœãŒã¹ãå°ãªããã©ã³ã¿ã€ã ãå¿
èŠãšããŸããã å€ãã®ã³ãŒãã¯å¿
èŠãããŸããã 倧éã®ããŒãã³ã³ãã¥ãŒãã£ã³ã°äœæ¥ãè¡ãå°ããªã¢ãžã¥ãŒã«ãããå Žåã¯ãRustã®è¡ãããã€ãå®è£
ããŠé床ãäžããŠãã ããã
Rustã³ãŒãã®
web-sysããã³js-sysã¯ã¬ãŒãã䜿çšãããšã
fetch
ã
appendChild
ãªã©ã®Web APIãç°¡åã«åŒã³åºãããšãã§ã
appendChild
ã ãŸãã
wasm-bindgen
ãããšãWebAssemblyããã€ãã£ãã«ãµããŒãããŠããªãé«ã¬ãã«ã®ããŒã¿åãç°¡åã«ãµããŒãã§ããŸãã
Rust WebAssemblyã¢ãžã¥ãŒã«ãèšè¿°ããåŸãWebã¢ããªã±ãŒã·ã§ã³ã®æ®ãã®éšåã«ç°¡åã«æ¥ç¶ããããŒã«ããããŸãã
wasm-packã䜿çšããŠãããã®ããŒã«ãèªåçã«èµ·åããå¿
èŠã«å¿ããŠnpmã§ã¢ãžã¥ãŒã«ãå®è¡ã§ããŸãã
詳现ã«ã€ããŠã¯ã
æ¬Rust and WebAssemblyãåç
§ããŠ
ãã ãã ã
次ã¯ïŒ
Rust 2018ã®ãªãªãŒã¹åŸãéçºè
ã¯ãã©ã®åéã§ããã«äœæ¥ãé²ãããã«ã€ããŠã³ãã¥ããã£ãšè©±ãåãäºå®ã§ãã
çµã¿èŸŒã¿ã¢ããªã±ãŒã·ã§ã³
çµã¿èŸŒã¿éçºã§ã¯ãæ¢åã®æ©èœã®å®å®æ§ãé«ããå¿
èŠããããŸããã
çè«çã«ã¯ãRustã¯åžžã«çµã¿èŸŒã¿ã¢ããªã±ãŒã·ã§ã³ã«é©ããèšèªã§ããã ããã¯ãéçºè
ã«ãšã£ãŠéåžžã«æ¬ ããŠããææ°ã®ããŒã«ãããã§ãããéåžžã«äŸ¿å©ãªé«ã¬ãã«èšèªæ©èœã§ãã ããããã¹ãŠã¯ãCPUãšã¡ã¢ãªã«äžå¿
èŠãªè² è·ããããããšãªãè¡ãããŸãã ãããã£ãŠãRustã¯çµã¿èŸŒã¿ã«æé©ã§ãã
ããããå®éã«ã¯ããã¯ç°ãªã£ãŠå€æããŸããã
å®å®ãããã£ãã«ã«ã¯å¿
èŠãªæ©èœããããŸããã§ããã ããã«ãçµã¿èŸŒã¿ããã€ã¹ã§äœ¿çšããã«ã¯ãæšæºã©ã€ãã©ãªãå€æŽããå¿
èŠããããŸããã ã€ãŸãã人ã
ã¯ç¬èªã®ããŒãžã§ã³ã®Rustã³ã¢ã¯ã¬ãŒãïŒãã¹ãŠã®Rustã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšãããRustã®åºæ¬çãªæ§æèŠçŽ ã§ããçµã¿èŸŒã¿é¢æ°ãšããªããã£ããæäŸããã¯ã¬ãŒãïŒãã³ã³ãã€ã«ããå¿
èŠããããŸããã
ãã®çµæãéçºè
ã¯Rustã®å®éšããŒãžã§ã³ã«äŸåããŠããŸããã ãŸããèªåãã¹ãããªãå Žåãå®éšã¢ã»ã³ããªã¯ãã€ã¯ãã³ã³ãããŒã©ãŒã§æ©èœããªãããšããããããŸããã
ãããä¿®æ£ããããã«ãéçºè
ã¯å¿
èŠãªãã¹ãŠã®æ©èœãå®å®ãããã£ãã«ã«è»¢éãããã€ã¯ãã³ã³ãããŒã©ãŒã®CIã·ã¹ãã ã«ãã¹ããè¿œå ããããšããŸããã ããã¯ããã¹ã¯ãããã³ã³ããŒãã³ããå€æŽããŠããçµã¿èŸŒã¿ããŒãžã§ã³ãå£ããªãããšãæå³ããŸãã
ãã®ãããªå€æŽã«ãããRustã§ã®çµã¿èŸŒã¿ã·ã¹ãã ã®éçºã¯ãé«åºŠãªå®éšã®åéããéåžžã®å¹çã®åéã«ç§»è¡ããŠããŸãã
詳现ã«ã€ããŠã¯ã
æžç±Rust for Embedded Systemsãåç
§ããŠãã ããã
次ã¯ïŒ
ä»å¹ŽãRustã¯äººæ°ã®ããARM Cortex-Mãã¡ããªã«å¯ŸããŠéåžžã«è¯ããµããŒããåŸãŸããã ãã ããå€ãã®ã¢ãŒããã¯ãã£ã¯ãŸã ååã«ãµããŒããããŠããŸããã Rustãæ¡åŒµããŠãä»ã®ã¢ãŒããã¯ãã£ã«åæ§ã®ãµããŒããæäŸããå¿
èŠããããŸãã
ãããã¯ãŒã¯ã¿ã¹ã¯
ãããã¯ãŒã¯ã§åäœããããã«ã¯ãããŒã«æœè±¡åãèšèªã«åã蟌ãå¿
èŠããããŸããïŒ
async/await
ã ãããã£ãŠãéçºè
ã¯éåæã³ãŒãã§ãæšæºã®Rustã€ãã£ãªã ã䜿çšã§ããŸãã
ãããã¯ãŒã¯ã¿ã¹ã¯ã§ã¯ãå€ãã®å ŽåãåŸ
æ©ããå¿
èŠããããŸãã ããšãã°ããªã¯ãšã¹ããžã®å¿çã ã³ãŒããåæã®å Žåãäœæ¥ã¯åæ¢ããŸããã³ãŒããå®è¡ãããããã»ããµã®ã³ã¢ã¯ããªã¯ãšã¹ããå°çãããŸã§äœãã§ããŸããã ãã ããéåæã³ãŒãã§ã¯ããã®ãããªé¢æ°ãã¹ã¿ã³ãã€ã¢ãŒãã«ãããšãCPUã³ã¢ãæ®ããå®è¡ã§ããŸãã
Rust 2015ã§ã¯éåæããã°ã©ãã³ã°ãå¯èœã§ããããã«ã¯å€ãã®å©ç¹ããããŸãã é«æ§èœã¢ããªã±ãŒã·ã§ã³ã§ã¯ããµãŒããŒã¢ããªã±ãŒã·ã§ã³ãåãµãŒããŒãžã®æ¥ç¶ãã¯ããã«å€ãåŠçããŸãã å°ããªã·ã³ã°ã«ã¹ã¬ããCPUäžã®çµã¿èŸŒã¿ã¢ããªã±ãŒã·ã§ã³ã¯ãã·ã³ã°ã«ã¹ã¬ããã®äœ¿çšãæé©åããŸãã
ãããããããã®å©ç¹ã«ã¯å€§ããªæ¬ ç¹ã䌎ããŸãããã®ãããªã³ãŒãã§ã¯ãåçšæ€èšŒãæ©èœãããéæšæºã®ïŒãããŠå°ãæ··ä¹±ããïŒRustã€ãã£ãªã ã䜿çšããå¿
èŠããããŸãã ããã¯
async/await
å©ç¹ã§ãã ããã«ãããã³ã³ãã€ã©ãŒã¯éåæé¢æ°åŒã³åºãã®åçšã確èªããããã«å¿
èŠãªæ
å ±ãåŸãããšãã§ããŸãã
async/await
ããŒã¯ãŒãã¯ããŒãžã§ã³1.31ã§å®è£
ãã
async/await
ããçŸåšå®è£
ã§ã¯ãµããŒããããŠããŸããã ã»ãšãã©ã®äœæ¥ã¯å®äºããŠããããã®æ©èœã¯æ¬¡ã®ãªãªãŒã¹ã§å©çšå¯èœã«ãªãã¯ãã§ãã
次ã¯ïŒ
å¹æçãªäœã¬ãã«éçºã«å ããŠãRustã¯ããé«ã¬ãã«ã®ãããã¯ãŒã¯ã¢ããªã±ãŒã·ã§ã³ã®ããå¹ççãªéçºãæäŸã§ããŸãã
å€ãã®ãµãŒããŒã¯ãURLã®è§£æãHTTPã®äœ¿çšãªã©ãæ¥åžžçãªã¿ã¹ã¯ãå®è¡ããŠããŸãã ããããã³ã³ããŒãã³ãïŒã¯ã¬ãŒããšããŠå
±æãããäžè¬çãªæœè±¡åïŒã«å€æãããšãããããç°¡åã«æ¥ç¶ããŠãããããçš®é¡ã®ãµãŒããŒããã³ãã¬ãŒã ã¯ãŒã¯æ§æã圢æã§ããŸãã
ã³ã³ããŒãã³ããéçºããã³ãã¹ãããããã«ãå®éšçãª
Tideãã¬ãŒã ã¯ãŒã¯ãäœæ
ãããŸããã
ã³ãã³ãã©ã€ã³ããŒã«
ã³ãã³ãã©ã€ã³ããŒã«ã®å Žåãå°ããªäœã¬ãã«ã®ã©ã€ãã©ãªãçµã¿åãããŠé«ã¬ãã«ã®æœè±¡åãè¡ããããã€ãã®æ¢åã®ããŒã«ãæŽç·Žããå¿
èŠããããŸããã
äžéšã®ã¹ã¯ãªããã§ã¯ãbashãçæ³çã§ãã ããšãã°ãä»ã®ã·ã§ã«ããŒã«ãåŒã³åºããŠããããã®éã§ããŒã¿ãæž¡ãã ãã§ãã
ããããRustã¯ä»ã®å€ãã®ããŒã«ã«ãšã£ãŠçŽ æŽããããªãã·ã§ã³ã§ãã ããšãã°ãæ¢åã®ã©ã€ãã©ãªã®æ©èœã®äžã«
ripgrepãªã©ã®è€éãªããŒã«ãCLIããŒã«ãäœæããå Žåã
Rustã¯ã©ã³ã¿ã€ã ãå¿
èŠãšãããåäžã®éçãã€ããªã«ã³ã³ãã€ã«ãããããããã°ã©ã ã®é
åžãç°¡åã«ãªããŸãã ãããŠãCãC ++ãªã©ãä»ã®èšèªã«ã¯ãªãé«ã¬ãã«ã®æœè±¡åãååŸããŸãã
Rustãæ¹åã§ãããã®ã¯ä»ã«ãããŸããïŒ ãã¡ãããããã«é«ãã¬ãã«ã®æœè±¡åã
é«ã¬ãã«ã®æœè±¡åã«ãããæ¢è£œã®CLIããã°ããç°¡åã«çµã¿ç«ãŠãããšãã§ããŸãã
ãã®ãããªæœè±¡åã®äŸã¯ã
人éã®ãããã¯ã©ã€ãã©ãªã§ãã ãã®ãããªã©ã€ãã©ãªããªãå Žåãé害ãçºçããå ŽåãCLIã³ãŒãã¯ãããããã¹ãŠã®ããã¯ãã©ãã¯ãè¿ããŸãã ãããããŠãŒã¶ãŒã«ãšã£ãŠã¯ããŸãé¢çœããªãã ã«ã¹ã¿ã ãšã©ãŒåŠçãè¿œå ã§ããŸãããããã¯å°é£ã§ãã
ãã¥ãŒãã³ãããã¯ã©ã€ãã©ãªã§ã¯ãåºåã¯èªåçã«ãšã©ãŒãã³ããã¡ã€ã«ã«éãããŸãã ãŠãŒã¶ãŒã«ã¯ãåé¡ãå ±åããŠãã³ããã¡ã€ã«ãããŠã³ããŒãããããã®æ
å ±ã¡ãã»ãŒãžã衚瀺ãããŸãã
CLIããŒã«ã®éçºãç°¡åã«ãªããŸããã ããšãã°ã
confyã©ã€ãã©ãªã¯æ§æãèªååããŸãã 圌ã¯2ã€ã®ããšã ããå°ããŸãã
- ã¢ããªã±ãŒã·ã§ã³ã®ååã¯äœã§ããïŒ
- ã©ã®ãããªæ§æãã©ã¡ãŒã¿ãŒãæäŸããŸããïŒã·ãªã¢ã«åããã³éã·ãªã¢ã«åã§ããæ§é ãšããŠå®çŸ©ããŸãïŒïŒ
Confyã¯ãä»ã®ãã¹ãŠãç¬èªã«æ±ºå®ããŸãã
次ã¯ïŒ
CLIã®å€ãã®ã¿ã¹ã¯ãæœè±¡åããŸããã ããããæœè±¡åãããã®ã¯ä»ã«ããããŸãã ãã®ãããªé«ã¬ãã«ã®ã©ã€ãã©ãªãããã«ãªãªãŒã¹ããäºå®ã§ãã
éããŒã«
ä»»æã®èšèªã§äœæããå Žåããã®ããŒã«ã䜿çšããŸãããšãã£ã¿ãŒããéå§ããéçºãšãµããŒãã®ãã¹ãŠã®æ®µéã§ä»ã®ããŒã«ã䜿çšãç¶ããŸãã
ã€ãŸããå¹æçãªèšèªã¯å¹æçãªããŒã«ã«äŸåããŸãã
Rust 2018ã®æ°ããããŒã«ïŒããã³æ¢åã®ããŒã«ã®æ¹è¯ç¹ïŒã以äžã«ç€ºããŸãã
IDEãµããŒã
ãã¡ãããããã©ãŒãã³ã¹ã¯ãéçºè
ã®å¿ããã³ã³ãã¥ãŒã¿ãŒç»é¢ãžã®ã³ãŒãã®è¿
éãã€ã¹ã ãŒãºãªè»¢éã«äŸåããŸãã ããã§ã¯IDEã®ãµããŒããéèŠã§ãã ãã®ããã«ã¯ãIDEã«Rustã³ãŒãã®æå³ãã説æãã§ããããŒã«ãå¿
èŠã§ããããšãã°ãæååã®èªåè£å®ã«æå³ã®ãããªãã·ã§ã³ãææ¡ããŸãã
Rust 2018ã§ã¯ãã³ãã¥ããã£ã¯IDEã«å¿
èŠãªæ©èœã«çŠç¹ãåãããŸããã Rust Language ServerãšIntelliJ Rustã®ç»å Žã«ãããå€ãã®IDEãRustãå®å
šã«ãµããŒãããããã«ãªããŸããã
ããé«éãªã³ã³ãã€ã«
ã³ã³ãã€ã©ãŒã®ããã©ãŒãã³ã¹ãåäžãããããšã¯ããããé«éåããããšãæå³ããŸãã ãããç§ãã¡ãããããšã§ãã
以åã¯ãRustã¯ã¬ãŒããã³ã³ãã€ã«ãããšãã³ã³ãã€ã©ã¯ã¯ã¬ãŒãå
ã®ãã¹ãŠã®ãã¡ã€ã«ãåã³ã³ãã€ã«ããŠããŸããã å¢åã³ã³ãã€ã«ãå®è£
ãããŸãããå€æŽãããéšåã®ã¿ãã³ã³ãã€ã«ããŸãã ä»ã®æé©åãšãšãã«ãããã«ããRustã³ã³ãã€ã©ãŒã®é床ã倧å¹
ã«åäžããŸããã
rustfmt
ãŸããå¹çæ§ã®ããã«ã¯ãã³ãŒãã®ãã©ãŒãããèŠåã«ã€ããŠè°è«ããããä»ã®äººã®ã¹ã¿ã€ã«ãæåã§ä¿®æ£ãããããããšã¯æ±ºããŠãããŸããã
rustfmtããŒã«ã¯ããã«åœ¹ç«ã¡ãŸããããã©ã«ãã®ã¹ã¿ã€ã«ïŒ
ã³ãã¥ããã£ãåæã«éããã¹ã¿ã€ã«ïŒã«åŸã£ãŠã³ãŒããèªåçã«åãã©ãŒãããããŸãã Rustfmtã¯ããã¹ãŠã®Rustã³ãŒããC ++ã®clang圢åŒãŸãã¯JavaScriptã®Prettierã«äŒŒãåãã¹ã¿ã€ã«ã«æºæ ããããšãä¿èšŒããŸãã
Clippy
ã³ãŒããäœæããããã®ãã¹ããã©ã¯ãã£ã¹ã«é¢ãããã³ããæäŸããçµéšè±å¯ãªã³ã³ãµã«ã¿ã³ããè¿ãã«ãããšäŸ¿å©ãªå ŽåããããŸãã ãããClippyã®åäœã§ãã衚瀺äžã«ã³ãŒãããã§ãã¯ããæšæºçãªã€ãã£ãªã ãææ¡ããŸãã
ãã³ã
ããããå€ãã€ãã£ãªã ãæã€å€ãã³ãŒãããŒã¹ãããå Žåã¯ãã³ãŒããåå¥ã«æ€èšŒããã³ä¿®æ£ããã®ã¯é¢åã§ãã 誰ãã«ã³ãŒãããŒã¹å
šäœãä¿®æ£ããŠãããããã ãã§ãã
ãããã®å Žåãrustfixã¯ããã»ã¹ãèªååããŸãã Clippyãªã©ã®ããŒã«ããåæã«ã«ãŒã«ãé©çšããRust 2018ã®ã€ãã£ãªã ã«åŸã£ãŠå€ãã³ãŒããæŽæ°ããŸãã
Rustèªäœã®å€æŽ
ãšã³ã·ã¹ãã ã®å€åã«ãããããã°ã©ãã³ã°ã®å¹çã倧å¹
ã«åäžããŸããã ããããäžéšã®åé¡ã¯èšèªèªäœã®å€æŽã«ãã£ãŠã®ã¿è§£æ±ºã§ããŸãã
ã¯ããã«è¿°ã¹ãããã«ãã»ãšãã©ã®èšèªã®å€æŽã¯æ¢åã®Rustã³ãŒããšå®å
šã«äºææ§ããããŸãã ãããã®å€æŽã¯ãã¹ãŠRust 2018ã®äžéšã§ãããããããããã¯äœãå£ããªãã®ã§ãRustã³ãŒãã§åäœããŸã...å€ãã³ãŒãã§ãåäœããŸãã
ãã¹ãŠã®ããŒãžã§ã³ã«è¿œå ãããéèŠãªæ©èœãèŠãŠã¿ãŸãããã 次ã«ãRust 2018ã®æ©èœã®çããªã¹ããã芧ãã ããã
ãã¹ãŠã®ããŒãžã§ã³ã®æ°æ©èœ
以äžã¯ãèšèªã®ãã¹ãŠã®ããŒãžã§ã³ã«å«ãŸããïŒãŸãã¯å«ãŸããäºå®ã®ïŒæ°æ©èœã®å°ããªäŸã§ãã
ããæ£ç¢ºãªåå
¥æ€èšŒ
Rustã®å€§ããªå©ç¹ã®1ã€ã¯ãåå
¥æ€èšŒã§ãã ã³ãŒããã¡ã¢ãªã»ãŒãã§ããããšãä¿èšŒããŸãã ããããRustã®åå¿è
ã«ãšã£ãŠã¯ããªãè€éãªæ©èœã§ããããŸãã
é£ããã®äžéšã¯ãæ°ããæŠå¿µãåŠã¶ããšã«ãããŸãã ããããå¥ã®éšåããããŸã...åçšããã¹ããããšãã¡ã¢ãªã®å®å
šæ§ã®æŠå¿µãå®å
šã«ç解ããŠããããã°ã©ããŒã®èŠ³ç¹ããã¯æ©èœããŠããããã«èŠããã³ãŒããæåŠãããããšããããŸãã
å€æ°ã¯æ¢ã«åçšãããŠãããããåçšã§ããŸããããã¯ãåçšã©ã€ãã¿ã€ã ããã£ãŒã«ãã®çµãããŸã§ïŒããšãã°ãå€æ°ãé
眮ãããŠããé¢æ°ã®çµãããŸã§ïŒå»¶é·ãããããšã«ãªã£ãŠããããã«çºçããŸãã
ã€ãŸããå€æ°ãå€ã®åŠçãçµäºããã¢ã¯ã»ã¹ãè©Šè¡ããªããªã£ãŠããä»ã®å€æ°ã¯é¢æ°ã®çµäºãŸã§ãã®å€ãžã®ã¢ã¯ã»ã¹ãæåŠãããŸãã
ç¶æ³ãä¿®æ£ããããã«ããã§ãã¯ãããã¹ããŒãã«ããŸããã ããã§ãå€æ°ãå€ã®äœ¿çšã
å®éã«çµäºããããšãããããŸãã ãã®åŸãããŒã¿ã®äœ¿çšã¯ãããã¯ãããŸããã
ããã¯Rust 2018ã§ã®ã¿äœ¿çšå¯èœã§ãããè¿ãå°æ¥ããã®æ©èœã¯ä»ã®ãã¹ãŠã®ããŒãžã§ã³ã«è¿œå ãããäºå®ã§ãã ããã«ãã®ãããã¯ã«ã€ããŠè©³ãã説æããŸãã
å®å®ããéã®æç¶ããã¯ã
Rustã®ãã¯ãã¯ãRust 1.0ããåã«ååšããŠããŸããã ããããRust 2018ã§ã¯ãããšãã°æç¶ãåãã¯ããç»å Žãããªã©ãæ·±å»ãªæ¹åãè¡ãããŸããã Rustã«ç¬èªã®æ§æãè¿œå ã§ããŸãã
Rust 2018ã¯ã2çš®é¡ã®æç¶ããã¯ããæäŸããŸãã
é¢æ°ãã¯ã
é¢æ°ã®ãããªãã¯ãã䜿çšãããšãéåžžã®é¢æ°åŒã³åºãã®ããã«èŠããããå®éã«ã¯ã³ã³ãã€ã«æã«å®è¡ããããªããžã§ã¯ããäœæã§ããŸãã 圌ãã¯1ã€ã®ã³ãŒããåãåããå¥ã®ã³ãŒããæäŸããã³ã³ãã€ã©ã¯ããããã€ããªã«æ¿å
¥ããŸãã
以åã¯ååšããŠããŸããããéãããŠããŸããã ãã¯ãã¯äžèŽã¹ããŒãã¡ã³ãã®ã¿ãå®è¡ã§ããŸãã 圌ã¯ãçä¿¡ã³ãŒãå
ã®ãã¹ãŠã®ããŒã¯ã³ã衚瀺ããã¢ã¯ã»ã¹æš©ãæã£ãŠããŸããã§ããã
ããããæç¶ãåãã¯ãã䜿çšãããšãããŒãµãŒãšåãå
¥åãã€ãŸãåãããŒã¯ã³ã¹ããªãŒã ãååŸã§ããŸãã ããã¯ãé¢æ°ã®ãããªã¯ããã«åŒ·åãªãã¯ããäœæã§ããããšãæå³ããŸãã
å±æ§ã®ãããªãã¯ã
JavaScriptã®ãããªèšèªã®ãã³ã¬ãŒã¿ã«ç²ŸéããŠããå Žåãå±æ§ãã¯ãã¯éåžžã«ãã䌌ãŠããŸãã ãããã䜿çšãããšãååŠçããŠä»ã®äœãã«å€æããå¿
èŠãããRustã³ãŒãã®ãã©ã°ã¡ã³ãã«æ³šéãä»ããããšãã§ããŸãã
derive
ãã¯ãã¯ãŸãã«ãããè¡ããŸãã æ§é äœã«éãããšãã³ã³ãã€ã©ãŒã¯ïŒããŒã¯ã³ã®ãªã¹ããšããŠè§£æãããåŸã«ïŒãã®æ§é äœãååŸããŠåŠçããŸãã ç¹ã«ããã¬ã€ãããã®é¢æ°ã®åºæ¬çãªå®è£
ãè¿œå ããŸãã
æ¯èŒã«ããããã人éå·¥åŠçãªåå
¥
ç°¡åãªå€æŽããããŸãã
以åã¯ãäœããåããŠäžèŽãããããšããå Žåãå¥åŠãªæ§æãè¿œå ããå¿
èŠããããŸããã
ä»
&Some(ref s)
代ããã«
&Some(ref s)
åã«
Some(s)
æžããŸãã
Rust 2018ã®æ°æ©èœ
Rust 2018ã®æå°éšåã¯ããã®ããŒãžã§ã³ã«åºæã®æ©èœã§ãã Rust 2018ã®å°ããªå€æŽç¹ã以äžã«ç€ºããŸãã
ããŒã¯ãŒã
Rust 2018ã¯ããã€ãã®ããŒã¯ãŒããè¿œå ããŸããïŒ
ãããã®æ©èœã¯ãŸã å®å
šã«ã¯å®è£
ãããŠããŸããããRust 1.31ã§ããŒã¯ãŒããè¿œå ãããŸããã
ãããã£ãŠãå°æ¥ããããã®æ©èœãå®è£
ãããšãã«æ°ããããŒã¯ãŒããå°å
¥ããå¿
èŠã¯ãªããªããŸãïŒããã¯äºææ§ã®ãªãå€æŽã«ãªããŸãïŒãã¢ãžã¥ã©ãŒã·ã¹ãã
Rustã®åå¿è
ã«ãšã£ãŠå€§ããªèŠçã®1ã€ã¯ãã¢ãžã¥ã©ãŒã·ã¹ãã ã§ãããããŠããã®çç±ã¯æããã§ããRustãç¹å®ã®ã¢ãžã¥ãŒã«ãéžæããçç±ãç解ããããšã¯å°é£ã§ããããããä¿®æ£ããããã«ããã¹ã¡ã«ããºã ã«ããã€ãã®å€æŽãå ããŸãããããšãã°ãã©ãã¯ãã€ã³ããŒãããå Žåãæäžäœã®ãã¹ã§äœ¿çšã§ããŸãããã ããã³ãŒãããµãã¢ãžã¥ãŒã«ã«ç§»åãããšãæ©èœããªããªããŸãã
å¥ã®äŸã¯ã::
ã¯ã¬ãŒãã®ã«ãŒããšå€éšã¯ã¬ãŒãã®äž¡æ¹ã«äœ¿çšããããã¬ãã£ãã¯ã¹ã§ããç§ãã¡ã®åã«ãããã®ãç解ããããšã¯å°é£ã§ããããæ確ã«ããŸãããã«ãŒãã©ãã¯ãåç
§ããå Žåã¯ããã¬ãã£ãã¯ã¹ã䜿çšããŸãcrate::
ãããã¯ãããããããããããã®æ¹åç¹ã®1ã€ã«ãããŸãããçŸåšã®ã³ãŒãã§Rust 2018ã®æ©èœã䜿çšããå Žåãã»ãšãã©ã®å Žåãæ°ãããã¹ãåæ ããããã«ã³ãŒããæŽæ°ããå¿
èŠããããŸãããã ãããããæåã§è¡ãå¿
èŠã¯ãããŸãããCargo.tomlã«ããŒãžã§ã³æå®åãè¿œå ããåã«ãããcargo fix
ãå®è¡ãrustfix
ãŠå¿
èŠãªå€æŽãå ããŸããè¿œå æ
å ±
èšèªã®æ°ããããŒãžã§ã³ã«é¢ãããã¹ãŠã®æ
å ±ã¯ãRust 2018ã¬ã€ãã«å«ãŸããŠããŸãã