2017-05-01ãã1ã¶æéã®è¨äºä¸è¦§
Rustã«ã¯2種é¡ã®ã¹ã¬ãããã¼ã«ã«å¤æ°ãããã #[thread_local] å±æ§ #[thread_local] å±æ§ã¯ãæå®ãã static ã¢ã¤ãã ãã¹ã¬ãããã¼ã«ã«ã«ããããã«LLVMã«ä¼ãããããã«ããCè¨èªã®ã¹ã¬ãããã¼ã«ã«å¤æ°ã¨åæ§ã«ãELFãªã³ã«å´ã®å¦çã«ããã¹ã¬ãããã¼â¦
æ¦è¦: Rustã«ããããã¼ã¯ã¼ãã®å½¹å²ãã§ããéãåæããããã¼ã¯ã¼ãã§ã¯ãªããã®ã«ã¤ãã¦ãä¸é¨åãä¸ããã å¼·ãã¼ã¯ã¼ãé¨é ãã¼ã¯ã¼ã å½¹å² as 修飾ãã¹ <T as Tr>::foo useã¨extern crateã«ãããå¥å use foo as bar; åã®å¤æ x as usize box boxå¼ box 1 b</t>â¦
æ¦è¦: Rustã«ãããè¨å·ã®å½¹å²ãã§ããéãåæããã ASCIIå¶å¾¡æåé¨é æå å½¹å² HT (æ°´å¹³ã¿ã) ç©ºç½ LF (ã©ã¤ã³ãã£ã¼ã) 空ç½æååä¸ã®æ¹è¡ã·ãã³ #! ãè¡ã³ã¡ã³ã // ã®çµãã VT (åç´ã¿ã) ç©ºç½ CR (ãã£ãªãã¸ãªã¿ã¼ã³) 空ç½CRLFã§LFã¨ç価ã«æ¯ãâ¦
Rustã® FnBox ã«ã¤ãã¦ãåæ©ã»ä»çµã¿ã»åé¡ç¹ã説æããã FnBox ã®åæ© ä»¥åã®è¨äºã§ã¯ãããã¯ãã¼ã¸ã£ã boxããã« è¿ããããã¨ãã欲æ±ã¯äººé¡ã®å大欲æ±ã®ã²ã¨ã¤ã¨è¨ããã¦ããã ãã¨æ¸ããããåºæã®ç°ãªãã¯ãã¼ã¸ã£ãåãåã§æ±ãå¿ è¦ãããå ´åã¯â¦
éå»ã®è¨äºã§Sizedã«ã¤ãã¦èª¬æããããé¢æ°ã®å¼æ°ã¨æ»ãå¤ã«ã¤ãã¦ã¯ããç´æã«åããæ¡ä»¶ãé©ç¨ããã¦ããã®ã§èª¬æããã æ»ãå¤å: é¢æ°ãã¡ã½ãããæ¬ä½ããã¤å ´åã«æ¤æ»ããããæ¬ä½ãæããªãå ´å㯠Sized ã§ãªãã¦ãããã å¼æ°å: ããèªä½ã¯æ¤æ»ãâ¦
æ¦è¦: UnsafeCell ã®åå¨ç®çã«ã¤ãã¦èª¬æããã UnsafeCell ã¨ã¯ UnsafeCell ã¨ã¯ããã®ååã®éããå é¨å¯å¤æ§(interior mutability)ãå®ç¾ããããã®unsafeã¯ããªããã£ãã§ããã UnsafeCell ã®ä»£è¡¨çãªç¨éã¯å é¨å¯å¤æ§ãå®ç¾ããããã®å®å ¨ãªã©ããã¼â¦
æ¦è¦: &mut åç §ã«å¯¾ãã¦ææ権ãå¿ è¦ãªæä½ãããã¨ãã¯ç¹å®ã®ãã¿ã¼ã³ãç¨ãããããããã身代ãããã¿ã¼ã³ã¨ã§ãå¼ã¶ãã¨ã«ããã ä¾: åæ¹åãªã³ã¯ãªã¹ã ã¾ããã¦ãåæ¹åãªã³ã¯ãªã¹ããèããã struct List<T> { root: Option<Box<Node<T>>>, } struct Node<T> { value</t></box<node<t></t>â¦
Rustã³ã³ãã¤ã©ã®ç´°ããæåã追ãã«ã¯ãã³ã³ãã¤ã©å ã«è¨ç½®ãã¦ãã debug!(..) ã®åºåã追ãæãããã ãããã°åºåãæå¹åãã¦ã³ã³ãã¤ã©ããã«ããã ã¾ãæå ã®Rustã³ã³ãã¤ã©ã®ã½ã¼ã¹ããããããã°åºåãæå¹åããã³ã³ãã¤ã©ãä½æããå¿ è¦ãããâ¦
æ¦è¦: Rustã®åºæ¬åãã®ãã®ã¯ã³ã³ãã¤ã©ã§ç¹å¥ã«å®ç¾©ããã¦ãããã§ã¯åã«é¢é£ã¥ããããã¡ã½ããã¯ã©ãã«ããã®ãã åºæã¡ã½ããã®ããã åºæã¡ã½ãã㯠core ã®åæã§å®ç¾©ããã¦ãããä¾ãã° i32 ã®åºæå®è£ 㯠core::numã«å®ç¾©ããã¦ããã #[lang = "iâ¦
Rustã®ãã¯ãã§Fizz Buzzãæ¸ãã¦ã¿ãã gist.github.com ãã®Fizz Buzzã¯ãã«ã¼ãã¨åæ°å¤å®ããã¯ãã§å¦çãã¦ããã10é²æ°ã¨ãã¦è¡¨ç¤ºããé¨åã¯ãã¯ãã§ã¯ãªãRustæ¬ä½ã«ä»»ãã¦ãããã åä½ã®èª¬æ Rustã® macro_rules! ã§ã¡ã¿ããã°ã©ãã³ã°ãè¡ãå ´åãâ¦
æ¦è¦: Typed Arenaã¯dropckã®ç®çã説æããããä¾ã«ãªã£ã¦ããã Typed Arenaã¨Drop 以å Typed Arenaã®ç´¹ä»è¨äº ãæ¸ãããããã®ã½ã¼ã¹ã³ã¼ãã«ä»¥ä¸ã®ããã« Drop ã®å®è£ ã足ãã¦ã¿ãã extern crate typed_arena; use std::cell::RefCell; use typed_areâ¦
æ¦è¦: Rustã®NULLãã¤ã³ã¿æé©åã«ã¤ãã¦èª¬æããã NULLãã¤ã³ã¿æé©åã¨ã¯ 以ä¸ã®ããã«ãã¤ã³ã¿åã®Optionããå ã®ãã¤ã³ã¿ã¨åããµã¤ãºã«ãªãæé©åã§ãããNULLãNoneã«å²ãå½ã¦ã¦ããã fn main() { println!("{}", std::mem::size_of::<Box<u32>>()); // 8 pri</box<u32>â¦
æ¦è¦: çåæéã®é¢ä¿ã§ãã«ã¼ãã§ã¯æ¸ããªããæ«å°¾å帰ã§ã¯æ¸ããã¢ã«ã´ãªãºã ã®ä¾ãæããã åæ¹åãªã³ã¯ãªã¹ã 次ã®ãããªåç´ãªãªã³ã¯ãªã¹ããèããã struct List<T> { root: Option<Box<Node<T>>>, } struct Node<T> { value: T, next: Option<Box<Node<T>>>, } backã®å®è£ åæ¹å</box<node<t></t></box<node<t></t>â¦
shebangã¯Rustã§ã¯ã³ã¡ã³ãã¨ã¿ãªãããã #!/bin/cat fn main() { println!("Hello, world!"); } shebangã¨ã¿ãªãããæ¡ä»¶ã¯ã ãã¡ã¤ã«(åå¥è§£æã®å¦çåä½)ã®å é ã§ããã #! ã§å§ã¾ã£ã¦ããã #![ ã§å§ã¾ã£ã¦ããªãã ã§ãããLF \n ã¾ãã¯ãã¡ã¤ã«ã®æ«â¦
Rustã¯ããã©ã«ãã§ã¯æ¬æ¥ã®åãçºæ®ããªãã試ãã«æé ãªãã³ããã¼ã¯ã3åããã試ãããã ããã20ï½100åç¨åº¦é ãã£ãã ãRust㧠ââ ãé«éã«ããæ¹æ³ããç¥ããã人ã¯ãã¾ããRustã³ã³ãã¤ã©ãæ¬æ¥ã®åãçºæ®ãã¦ããã確èªããã»ããããã Cargoã®å ´â¦