{"id":284778,"date":"2023-10-23T09:00:44","date_gmt":"2023-10-23T01:00:44","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=284778"},"modified":"2023-10-09T15:10:19","modified_gmt":"2023-10-09T07:10:19","slug":"rust-1-73","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/rust-1-73.html","title":{"rendered":"Rust 1.73.0\u53d1\u5e03"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nRust \u56e2\u961f\u5f88\u9ad8\u5174\u5730\u5ba3\u5e03 Rust \u7684\u65b0\u7248\u672c 1.73.0\u3002Rust \u662f\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u8ba9\u6bcf\u4e2a\u4eba\u90fd\u80fd\u6784\u5efa\u53ef\u9760\u3001\u9ad8\u6548\u7684\u8f6f\u4ef6\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u5982\u679c\u4f60\u5df2\u7ecf\u901a\u8fc7 rustup \u5b89\u88c5\u4e86\u4e4b\u524d\u7684 Rust \u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u83b7\u5f97 1.73.0\uff1a<\/p>\n

rustup update stable
\n\u5982\u679c\u8fd8\u6ca1\u6709\uff0c\u53ef\u4ee5\u4ece\u6211\u4eec\u7f51\u7ad9\u7684\u76f8\u5e94\u9875\u9762\u83b7\u53d6 rustup\uff0c\u5e76\u5728 GitHub \u4e0a\u67e5\u770b 1.73.0 \u7684\u8be6\u7ec6\u53d1\u5e03\u8bf4\u660e\u3002<\/p>\n

\u5982\u679c\u4f60\u60f3\u5e2e\u52a9\u6211\u4eec\u6d4b\u8bd5\u672a\u6765\u7684\u7248\u672c\uff0c\u53ef\u4ee5\u8003\u8651\u5728\u672c\u5730\u66f4\u65b0\uff0c\u4f7f\u7528 beta \u9891\u9053\uff08rustup \u9ed8\u8ba4 beta \u9891\u9053\uff09\u6216 nightly \u9891\u9053\uff08rustup \u9ed8\u8ba4 nightly \u9891\u9053\uff09\u3002\u8bf7\u62a5\u544a\u60a8\u53ef\u80fd\u9047\u5230\u7684\u4efb\u4f55 bug\uff01<\/p>\n

1.73.0 \u7a33\u5b9a\u7248\u4e2d\u7684\u5185\u5bb9<\/strong><\/div>\n
\u6e05\u7406panic\u7684\u4fe1\u606f<\/strong><\/span><\/div>\n

\u9ed8\u8ba4\u7d27\u6025\u5904\u7406\u7a0b\u5e8f\u7684\u8f93\u51fa\u5df2\u66f4\u6539\u4e3a\u5c06\u7d27\u6025\u4fe1\u606f\u653e\u5728\u5355\u72ec\u4e00\u884c\uff0c\u800c\u4e0d\u662f\u7528\u5f15\u53f7\u5c01\u88c5\u3002\u5982\u672c\u4f8b\u6240\u793a\uff0c\u8fd9\u5c06\u4f7fpanic\u4fe1\u606f\u66f4\u5bb9\u6613\u9605\u8bfb\uff1a<\/p>\n

fn main() {\r\n    let file = \"ferris.txt\";\r\n    panic!(\"oh no! {file:?} not found!\");\r\n}<\/pre>\n

\u4ece Rust 1.73 \u5f00\u59cb\u8f93\u51fa\uff1a<\/p>\n

thread 'main' panicked at 'oh no! \"ferris.txt\" not found!', src\/main.rs:3:5<\/pre>\n

\u4ece Rust 1.73 \u5f00\u59cb\u8f93\u51fa\uff1a<\/p>\n

thread 'main' panicked at src\/main.rs:3:5:\r\noh no! \"ferris.txt\" not found!<\/pre>\n

\u5f53\u4fe1\u606f\u8f83\u957f\u3001\u5305\u542b\u5d4c\u5957\u5f15\u53f7\u6216\u8de8\u591a\u884c\u65f6\uff0c\u8fd9\u4e00\u70b9\u5c24\u5176\u6709\u7528\u3002<\/p>\n

\u6b64\u5916\uff0c\u8fd8\u4fee\u6539\u4e86 assert_eq \u548c assert_ne \u4ea7\u751f\u7684\u6050\u614c\u4fe1\u606f\uff0c\u79fb\u52a8\u4e86\u81ea\u5b9a\u4e49\u4fe1\u606f\uff08\u7b2c\u4e09\u4e2a\u53c2\u6570\uff09\u5e76\u5220\u9664\u4e86\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u6807\u70b9\u7b26\u53f7\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

fn main() {\r\n    assert_eq!(\"\", \"\", \"ferris is not a fish\");\r\n}<\/pre>\n

Rust 1.73 \u4e4b\u524d\u7684\u8f93\u51fa\uff1a<\/p>\n

thread 'main' panicked at 'assertion failed: `(left == right)`\r\n left: `\"\"`,\r\nright: `\"\"`: ferris is not a fish', src\/main.rs:2:5<\/pre>\n

\u4ece Rust 1.73 \u5f00\u59cb\u8f93\u51fa\uff1a<\/p>\n

thread 'main' panicked at src\/main.rs:2:5:\r\nassertion `left == right` failed: ferris is not a fish\r\n left: \"\"\r\nright: \"\"<\/pre>\n
\u7ebf\u7a0b\u672c\u5730\u521d\u59cb\u5316<\/strong><\/span><\/div>\n

\u6b63\u5982 RFC 3184 \u6240\u5efa\u8bae\u7684\uff0cLocalKey> \u548c LocalKey> \u73b0\u5728\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 get()\u3001set()\u3001take() \u548c replace() \u65b9\u6cd5\u8fdb\u884c\u64cd\u4f5c\uff0c\u800c\u65e0\u9700\u50cf\u4e00\u822c LocalKey \u5de5\u4f5c\u90a3\u6837\u8df3\u8fc7 with(|inner| \u2026)\u95ed\u5305\u3002LocalKey<\/t> \u662f thread_local! \u72b6\u6001\u7684\u7c7b\u578b\u3002<\/p>\n

\u65b0\u65b9\u6cd5\u4f7f\u666e\u901a\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\uff0c\u5e76\u907f\u514d\u4e86\u4e3a\u65b0\u7ebf\u7a0b\u5728 thread_local! \u4e2d\u6307\u5b9a\u7684\u9ed8\u8ba4\u503c\u8fd0\u884c\u989d\u5916\u7684\u521d\u59cb\u5316\u4ee3\u7801\u3002<\/p>\n

thread_local! {\r\n    static THINGS: Cell> = Cell::new(Vec::new());\r\n}\r\n\r\nfn f() {\r\n    \/\/ before:\r\n    THINGS.with(|i| i.set(vec![1, 2, 3]));\r\n    \/\/ now:\r\n    THINGS.set(vec![1, 2, 3]);\r\n\r\n    \/\/ ...\r\n\r\n    \/\/ before:\r\n    let v = THINGS.with(|i| i.take());\r\n    \/\/ now:\r\n    let v: Vec<\/i32> = THINGS.take();\r\n}<\/i32><\/pre>\n
\u7a33\u5b9a\u7684 APIs<\/strong><\/span><\/div>\n
    \n
  1. Unsigned {integer}::div_ceil<\/li>\n
  2. Unsigned {integer}::next_multiple_of<\/li>\n
  3. Unsigned {integer}::checked_next_multiple_of<\/li>\n
  4. std::ffi::FromBytesUntilNulError<\/li>\n
  5. std::os::unix::fs::chown<\/li>\n
  6. std::os::unix::fs::fchown<\/li>\n
  7. std::os::unix::fs::lchown<\/li>\n
  8. LocalKey::>::get<\/t><\/li>\n
  9. LocalKey::>::set<\/t><\/li>\n
  10. LocalKey::>::take<\/t><\/li>\n
  11. LocalKey::>::replace<\/t><\/li>\n
  12. LocalKey::>::with_borrow<\/t><\/li>\n
  13. LocalKey::>::with_borrow_mut<\/t><\/li>\n
  14. LocalKey::>::set<\/t><\/li>\n
  15. LocalKey::>::take<\/t><\/li>\n
  16. LocalKey::>::replace<\/t><\/li>\n<\/ol>\n

    \u73b0\u5728\uff0c\u8fd9\u4e9b\u5e94\u7528\u7a0b\u5e8f\u63a5\u53e3\u5728\u5404\u79cd\u60c5\u51b5\u4e0b\u90fd\u5f88\u7a33\u5b9a\uff1a<\/p>\n

      \n
    1. rc::Weak::new<\/li>\n
    2. sync::Weak::new<\/li>\n
    3. NonNull::as_ref<\/li>\n<\/ol>\n

      <\/t><\/p>\n","protected":false},"excerpt":{"rendered":"

      \u5982\u679c\u4f60\u5df2\u7ecf\u901a\u8fc7 rustup \u5b89\u88c5\u4e86\u4e4b\u524d\u7684 Rust \u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u83b7\u5f97 1.73.0\uff1a rustu […]<\/p>\n","protected":false},"author":321,"featured_media":284780,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-284778","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/284778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=284778"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/284778\/revisions"}],"predecessor-version":[{"id":284895,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/284778\/revisions\/284895"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/284780"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=284778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=284778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=284778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}