Mike Yang on Nostr: 这个帮我大体搞明白了 ownership。 ownership 为了做 strict ...
这个帮我大体搞明白了 ownership。
ownership 为了做 strict checking,保证唯一存在,但为了方便,加了 move、borrow、mutable。mutable 想满足唯一,就要在一个 scope 里,一个变量只能有一个 mutable 的。有的变量会跳出 scope,编译器检查不出来,就得手动加 lifetime。没了。
Published at
2024-06-17 05:53:48Event JSON
{
"id": "b90eae0b3d63968f09bf16127e063f9dc867e4ba191411ba3c7c9f3503b898da",
"pubkey": "a2dd5e13313d4e18fc2a8dfc0dd564ff1b488a8c5c6773a7616bc7f978817af5",
"created_at": 1718596428,
"kind": 1,
"tags": [],
"content": "这个帮我大体搞明白了 ownership。\n\nownership 为了做 strict checking,保证唯一存在,但为了方便,加了 move、borrow、mutable。mutable 想满足唯一,就要在一个 scope 里,一个变量只能有一个 mutable 的。有的变量会跳出 scope,编译器检查不出来,就得手动加 lifetime。没了。",
"sig": "44ed18aad45dcf04aa936dbc1cf63afc50b88cdd770828e16d0e061a7d6b888ec877fb9e07fb8fec6caa319b639efcbefa571cb67909e2b63c0ec847d21e8715"
}