- プログラミング言語 Rust
315 :デフォルトの名無しさん[sage]:2015/06/27(土) 16:26:20.28 ID:wfeMnVHy - https://github.com/rust-lang/rust/issues/25899
これがなぜだか分からん。 fn main() { let a: &mut i32 = &mut 0; { let b = a; } let c = a; } 上が駄目で、下がおkな理由。 fn main() { let a: &mut i32 = &mut 0; { let b: &mut i32 = a; } let c = a; }
|
- プログラミング言語 Rust
317 :デフォルトの名無しさん[sage]:2015/06/27(土) 17:34:52.26 ID:wfeMnVHy - 上では move されるのに、下では borrow されるのか。
#![feature(core_intrinsics)] fn print_type_of<T>(_: &T) -> () { let type_name = unsafe { std::intrinsics::type_name::<T>() }; println!("{}", type_name); } これを入れて型を表示すると、上でも下でも b の型は同じ &'static mut i32 なのに、型注釈するだけで挙動が変わるのは違和感あるなあ。
|
- プログラミング言語 Rust
318 :デフォルトの名無しさん[sage]:2015/06/27(土) 17:35:27.20 ID:wfeMnVHy - >>316
ありがとう。うーむ悩ましい。
|