= box 10; let b: &int = &*a; // a が占有する int 型の値を参照 let c: Box<int> = a; // a の持つ所有権は c に移動する // 値の所有者が変わっても b は有効なのか? } Masanori Ogino (@omasanori) Rust 入門以前
because it is borrowed ref2.rs:5 let c: Box<int> = a; // a の持つ所有権は c に移動する ^ ref2.rs:4:20: 4:22 note: borrow of `*a` occurs here ref2.rs:4 let b: &int = &*a; // a が占有する int 型の値を参照 ^~ error: aborting due to previous error 参照に値を「貸して」いる間は 所有権を移動できない Masanori Ogino (@omasanori) Rust 入門以前
need to be mutable, #[warn(unused_mut)] on by default mut-to-imut.rs:8 let mut square = i * i; ^~~~~~~~~~ rustcに冗談は通じない (警告を無効にしない限り) (gcc や clang にある同等の警告オプションを ご存じの方はいらっしゃいませんか。 -Wall -Wextra では警告されませんでした) Masanori Ogino (@omasanori) Rust 入門以前
dangling.rs:4 return &i; ^ dangling.rs:2:23: 5:2 note: reference must be valid for the anonymous lifetime #1 defined on the block at 2:22... dangling.rs:2 fn dangling() -> &int { dangling.rs:3 let i = 1234; dangling.rs:4 return &i; dangling.rs:5 } dangling.rs:2:23: 5:2 note: ...but borrowed value is only valid for the block at 2:22 dangling.rs:2 fn dangling() -> &int { dangling.rs:3 let i = 1234; dangling.rs:4 return &i; dangling.rs:5 } error: aborting due to previous error Masanori Ogino (@omasanori) Rust 入門以前
"frustrated C++ developers". I mean, that's us. So if you are in a similar situation we're in, repeatedly finding yourself forced to pick C++ for systems-level work due to its performance and deployment characteristics, but would like something safer and less painful, we hope we can provide that. 出典: http://www.infoq.com/news/2012/08/Interview-Rust 強調は筆者に よる。 Masanori Ogino (@omasanori) Rust 入門以前