{"id":227524,"date":"2021-10-08T09:14:43","date_gmt":"2021-10-08T01:14:43","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=227524"},"modified":"2021-09-27T09:15:26","modified_gmt":"2021-09-27T01:15:26","slug":"introduction-to-rust","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/introduction-to-rust.html","title":{"rendered":"Rust \u6ce8\u91ca\u4ecb\u7ecd"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nRust \u8bed\u8a00\u662f\u4e00\u79cd\u9ad8\u6548\u3001\u53ef\u9760\u7684\u901a\u7528\u9ad8\u7ea7\u8bed\u8a00\u3002\u5176\u9ad8\u6548\u4e0d\u4ec5\u9650\u4e8e\u5f00\u53d1\u6548\u7387\uff0c\u5b83\u7684\u6267\u884c\u6548\u7387\u4e5f\u662f\u4ee4\u4eba\u79f0\u8d5e\u7684\uff0c\u662f\u4e00\u79cd\u5c11\u6709\u7684\u517c\u987e\u5f00\u53d1\u6548\u7387\u548c\u6267\u884c\u6548\u7387\u7684\u8bed\u8a00\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

Rust \u4e2d\u7684\u6ce8\u91ca\u65b9\u5f0f\u4e0e\u5176\u5b83\u8bed\u8a00\uff08C\u3001Java\uff09\u4e00\u6837\uff0c\u652f\u6301\u4e24\u79cd\u6ce8\u91ca\u65b9\u5f0f\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

\/\/ \u8fd9\u662f\u7b2c\u4e00\u79cd\u6ce8\u91ca\u65b9\u5f0f\r\n\/* \u8fd9\u662f\u7b2c\u4e8c\u79cd\u6ce8\u91ca\u65b9\u5f0f *\/\r\n\/* 
\r\n * \u591a\u884c\u6ce8\u91ca
\r\n * \u591a\u884c\u6ce8\u91ca
\r\n * \u591a\u884c\u6ce8\u91ca
\r\n *\/<\/span><\/span><\/span><\/pre>\n
\u7528\u4e8e\u8bf4\u660e\u6587\u6863\u7684\u6ce8\u91ca<\/strong><\/div>\n

\u5728 Rust \u4e2d\u4f7f\u7528 \/\/ \u53ef\u4ee5\u4f7f\u5176\u4e4b\u540e\u5230\u7b2c\u4e00\u4e2a\u6362\u884c\u7b26\u7684\u5185\u5bb9\u53d8\u6210\u6ce8\u91ca\u3002<\/p>\n

\u5728\u8fd9\u79cd\u89c4\u5219\u4e0b\uff0c\u4e09\u4e2a\u53cd\u659c\u6760 \/\/\/ \u4f9d\u7136\u662f\u5408\u6cd5\u7684\u6ce8\u91ca\u5f00\u59cb\u3002\u6240\u4ee5 Rust \u53ef\u4ee5\u7528 \/\/\/ \u4f5c\u4e3a\u8bf4\u660e\u6587\u6863\u6ce8\u91ca\u7684\u5f00\u5934\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

\/\/\/\u202fAdds\u202fone\u202fto\u202fthe\u202fnumber\u202fgiven. \r\n\/\/\/ \r\n\/\/\/\u202f#\u202fExamples \r\n\/\/\/ \r\n\/\/\/\u202f``` \r\n\/\/\/\u202flet x = add(1, 2); \r\n\/\/\/ \r\n\/\/\/\u202f``` \r\nfn<\/span> add(<\/span>a:<\/span> i32<\/span>,<\/span> b:<\/span> i32<\/span>)<\/span> -><\/span> i32<\/span> {\r\n    return<\/span> a +<\/span> b;\r\n}\r\n    
\r\nfn<\/span> main(<\/span>)<\/span> {\r\n    println!<\/span>(<\/span>\"{}\"<\/span>,<\/span>add(<\/span>2<\/span>,<\/span>3<\/span>)<\/span>)<\/span>;\r\n}<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/pre>\n

\u7a0b\u5e8f\u4e2d\u7684\u51fd\u6570 add \u5c31\u4f1a\u62e5\u6709\u4e00\u6bb5\u4f18\u96c5\u7684\u6ce8\u91ca\uff0c\u5e76\u53ef\u4ee5\u663e\u793a\u5728 IDE \u4e2d\uff1a
\n\"\"
\nTip\uff1aCargo \u5177\u6709 cargo doc \u529f\u80fd\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u547d\u4ee4\u5c06\u5de5\u7a0b\u4e2d\u7684\u8bf4\u660e\u6ce8\u91ca\u8f6c\u6362\u6210 HTML \u683c\u5f0f\u7684\u8bf4\u660e\u6587\u6863\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Rust \u4e2d\u7684\u6ce8\u91ca\u65b9\u5f0f\u4e0e\u5176\u5b83\u8bed\u8a00\uff08C\u3001Java\uff09\u4e00\u6837\uff0c\u652f\u6301\u4e24\u79cd\u6ce8\u91ca\u65b9\u5f0f\uff1a \u5b9e\u4f8b \/\/ \u8fd9\u662f\u7b2c\u4e00\u79cd\u6ce8\u91ca\u65b9\u5f0f \/* […]<\/p>\n","protected":false},"author":1470,"featured_media":227525,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-227524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227524","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\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=227524"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227524\/revisions"}],"predecessor-version":[{"id":227606,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227524\/revisions\/227606"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/227525"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=227524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=227524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=227524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}