deref corecionとか無関係っぽい
-
-
(1) 次のようなコードを考える: let mut x = (vec![],); let x = &mut x; x.0[x.0.len() - 1] = 0; // <-- compile error
1 reply 2 retweets 0 likesShow this thread -
(2) 3行目において、一時変数を省略せずに記述すると次のようなコードと等価になっている(多分) let tmp0 = &mut x.0; let tmp1 = &x.0; let tmp2 = Vec::len(tmp1); let tmp3 = tmp1 - 1; *std::ops::IndexMut(tmp0, tmp3) = 0;
1 reply 2 retweets 1 likeShow this thread
(3) tmp0を作る際にxの可変借用を消費する必要があり、この時点で以後xへのいかなる借用が禁止される。したがって、tmp1を作ろうとした時点でxの借用ができない。 ...と思ったがこれはおそらく誤り(そうでないと x.0[x.1.len() - 1] = 0 が有効である理由が説明できない)
10:56 AM - 3 Apr 2020
0 replies
1 retweet
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.