{"id":107299,"date":"2026-09-19T10:08:45","date_gmt":"2026-09-19T02:08:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/107299.html"},"modified":"2026-09-19T10:08:45","modified_gmt":"2026-09-19T02:08:45","slug":"%e5%9b%b0%e6%83%91%e6%98%af%e6%ad%a3%e5%b8%b8%e7%9a%84static-%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f%e7%ba%a6%e6%9d%9f%e6%9c%ac%e6%9d%a5%e5%b0%b1%e4%b8%8d%e7%ae%80%e5%8d%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/107299.html","title":{"rendered":"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260919020843-6aadeeab8b5b5.png\" alt=\"\" \/> &#039;static \u751f\u547d\u5468\u671f\u7ea6\u675f\u603b\u7ed9\u4eba\u4e00\u79cd\u4e0d\u597d\u62ff\u634f\u7684\u611f\u89c9&#xff0c;\u56e0\u4e3a\u5b83\u51fa\u73b0\u5728\u4e0d\u540c\u4f4d\u7f6e\u4e0a\u65f6\u542b\u4e49\u4e5f\u4f1a\u6709\u6240\u4e0d\u540c&#xff0c;\u9700\u8981\u4ed4\u7ec6\u7504\u522b\u3002\u6b64\u5916&#xff0c;\u5b83\u8fd8\u603b\u4f1a\u548c\u5176\u4ed6\u4e00\u4e9b\u673a\u5236\u5173\u8054\u7740\u4e00\u8d77\u51fa\u73b0&#xff0c;\u6bd4\u5982\u95ed\u5305\u3001Fn trait\u3001\u751f\u547d\u5468\u671f\u7ea6\u675f\u4ee5\u53ca\u591a\u7ebf\u7a0b\u573a\u666f&#xff0c;\u8fd9\u4f1a\u589e\u52a0\u7406\u89e3\u7684\u56f0\u96be\u5ea6&#xff0c;\u6240\u4ee5&#xff0c;\u5bf9 &#039;static \u611f\u5230\u56f0\u60d1\u662f\u6b63\u5e38\u7684\u3002\u672c\u6587\u4f1a\u5e26\u9886\u5927\u5bb6\u5168\u9762\u4e86\u89e3\u4e00\u4e0b &#039;static \u751f\u547d\u5468\u671f\u7ea6\u675f\u3002\u672c\u6587\u539f\u6587\u94fe\u63a5&#xff1a;https:\/\/laurence.blog.csdn.net\/article\/details\/165619915 \u7981\u6b62\u8f6c\u8f7d\u3002<\/p>\n<h2>1. \u4ece static \u53d8\u91cf\u8c08\u8d77<\/h2>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token class-name\">X<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token class-name\">Y<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8ddf\u5176\u4ed6\u8bed\u8a00\u4e00\u6837&#xff0c;static \u53d8\u91cf\u7684\u6839\u672c\u7279\u5f81\u662f&#xff1a;\u5b83\u7684\u6570\u636e\u4f1a\u88ab\u5199\u8fdb\u7a0b\u5e8f\u7684\u6570\u636e\u6bb5&#xff08;.rodata \/ .data \/ .bss&#xff09;&#xff0c;\u8fdb\u7a0b\u542f\u52a8\u65f6\u4f1a\u88c5\u8f7d\u5230\u5185\u5b58\u4e2d&#xff0c;\u7136\u540e\u4e00\u76f4\u6301\u7eed\u5230\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u5185\u5b58\u4f4d\u7f6e\u90fd\u4e0d\u4f1a\u53d1\u751f\u53d8\u52a8\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u901a\u5e38\u6765\u8bf4&#xff0c;static \u53d8\u91cf\u662f\u5168\u5c40\u6027\u7684&#xff0c;\u4f46\u8fd9\u4e0d\u662f\u7edd\u5bf9\u7684\u3002\u5e94\u8be5\u8fd9\u6837\u8bf4&#xff1a;static \u53d8\u91cf\u5177\u5907\u6210\u4e3a\u5168\u5c40\u53d8\u91cf\u7684\u6761\u4ef6&#xff0c;\u4f46\u662f\u5426\u662f\u5168\u5c40\u7684\u53d6\u51b3\u4e8e\u58f0\u660e\u5b83\u7684\u4f4d\u7f6e&#xff0c;\u56e0\u4e3a&#xff0c;\u9664\u4e86\u53ef\u4ee5\u5728 module \u7ea7\u522b\u58f0\u660e\u5916&#xff0c;\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728\u4e00\u4e2a\u51fd\u6570\u7684\u5c40\u90e8\u4f5c\u7528\u57df\u4e2d\u58f0\u660e\u4e00\u4e2a static \u53d8\u91cf&#xff0c;\u5b83\u540c\u6837\u662f\u653e\u5728\u6570\u636e\u6bb5&#xff0c;\u8fd0\u884c\u65f6\u52a0\u8f7d\u8fdb\u5185\u5b58\u7684&#xff0c;\u53ea\u4e0d\u8fc7&#xff0c;\u5b83\u58f0\u660e\u7684\u4f5c\u7528\u57df\u9650\u5236\u4e86\u5b83\u7684\u201c\u53ef\u89c1\u6027\u201d\u3002<\/p>\n<p>\u7ecf\u5e38\u4e0e static \u53d8\u91cf\u4e00\u8d77\u6bd4\u8f83\u7684\u662f const \u5e38\u91cf&#xff0c;static \u53d8\u91cf\u6709\u81ea\u5df1\u786e\u5207\u7684\u5185\u5b58\u5730\u5740&#xff0c;\u53ef\u4ee5\u5bf9\u5b83&#xff1a;\u53d6\u5f15\u7528\u3001\u53d6\u5730\u5740&#xff0c;\u800c const \u5e38\u91cf\u66f4\u50cf\u662f\u5b83\u4ee3\u8868\u7684\u90a3\u4e2a\u503c\u7684\u201c\u522b\u540d\u201d&#xff0c;\u5b83\u6ca1\u6709\u81ea\u5df1\u7684\u5185\u5b58\u5730\u5740&#xff0c;\u5728\u7f16\u8bd1\u65f6&#xff0c;\u9047\u5230\u4f7f\u7528\u5230\u5b83\u7684\u5730\u65b9&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u5c31\u5730\u7269\u5316\u4e00\u4efd\u8fd9\u4e2a\u503c\u3002<\/p>\n<h2>2. &#039;static \u751f\u547d\u5468\u671f\u7ea6\u675f<\/h2>\n<p>&#039;static \u8868\u793a\u5176\u6807\u8bb0\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\u662f\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u5bf9\u8c61\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u4f1a\u4e00\u76f4\u5b58\u6d3b&#xff0c;\u7ed3\u5408\u5b83\u6240\u5904\u7684\u201c\u4e0a\u4e0b\u6587\u201d&#xff08;\u6240\u5904\u7684\u4f4d\u7f6e&#xff09;&#xff0c;&#039;static \u53ef\u4ee5\u51fa\u73b0\u5728\u56db\u79cd\u4f4d\u7f6e\u4e0a&#xff0c;\u4ee5\u53ca\u4e00\u79cd\u5bb9\u6613\u88ab\u8ba4\u4e3a\u662f\u53ef\u80fd\u7684\u4f4d\u7f6e&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u662f\u4e0d\u5141\u8bb8\u7684&#xff0c;\u4ee5\u4e0b\u662f\u5177\u4f53\u63cf\u8ff0\u548c\u793a\u4f8b&#xff1a;<\/p>\n<table>\n<tr>\u51fa\u73b0\u7684\u4f4d\u7f6e\u4f5c\u7528\u793a\u4f8b\u662f\u5426\u5408\u6cd5<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u4fee\u9970\u5f15\u7528<\/td>\n<td align=\"left\">\u58f0\u660e\u5f15\u7528\u53ef\u4ee5\u6d3b\u5230\u7a0b\u5e8f\u7ed3\u675f<\/td>\n<td align=\"left\">let s: &amp;&#039;static str &#061; \u201chello\u201d<\/td>\n<td align=\"left\">\u2611<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f<\/td>\n<td align=\"left\">\u7ea6\u675f\u7c7b\u578b\u4e0d\u5f97\u542b\u6709\u5916\u90e8\u5f15\u7528<\/td>\n<td align=\"left\">T: &#039;static<\/td>\n<td align=\"left\">\u2611<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">supertrait \u7684\u4f4d\u7f6e\u4e0a&#xff08;\u4f9d\u7136\u662f\u7c7b\u578b\u7ea6\u675f&#xff09;<\/td>\n<td align=\"left\">\u7ea6\u675f\u5b9e\u73b0\u8005\u4e0d\u5f97\u542b\u6709\u5916\u90e8\u5f15\u7528<\/td>\n<td align=\"left\">trait Foo: &#039;static {\u2026}<\/td>\n<td align=\"left\">\u2611<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7ed3\u6784\u4f53\u7c7b\u578b\u7684\u5c16\u62ec\u53f7\u4e2d<\/td>\n<td align=\"left\">\u4f5c\u4e3a\u4e00\u4e2a\u5177\u4f53\u7684\u751f\u547d\u5468\u671f\u7c7b\u578b<\/td>\n<td align=\"left\">b: Bar&lt;&#039;static&gt;<\/td>\n<td align=\"left\">\u2611<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7ed3\u6784\u4f53\u5b9a\u4e49\u7684\u5c16\u62ec\u53f7\u4e2d<\/td>\n<td align=\"left\">\u4e0d\u5408\u6cd5<\/td>\n<td align=\"left\">struct Bar&lt;&#039;static&gt; {\u2026} \/\/ error!<\/td>\n<td align=\"left\">\u2612<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.1 \u4fee\u9970\u5f15\u7528<\/h3>\n<p>\u4f7f\u7528 &#039;static \u4fee\u9970\u4e00\u4e2a\u5f15\u7528\u65f6\u610f\u601d\u662f\u201c\u8fd9\u4e2a\u5f15\u7528\u80fd\u4e00\u76f4\u6d3b\u5230\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u4e5f\u5c31\u662f\u201c\u4f60\u60f3\u6301\u6709\u591a\u4e45\u90fd\u884c\u201d\u3002\u663e\u7136&#xff0c;\u4e0d\u662f\u968f\u4fbf\u4ec0\u4e48\u5f15\u7528\u52a0\u4e0a\u4e2a &#039;static \u4fee\u9970\u5c31\u80fd\u6d3b\u5230\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u5f15\u7528\u7684\u201c\u5e95\u6c14\u201d\u6765\u81ea\u4e8e\u5b83\u7684\u503c&#xff0c;\u662f\u56e0\u4e3a\u5f15\u7528\u7684\u503c\u80fd\u201c\u8d2f\u7a7f\u7a0b\u5e8f\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u201d&#xff0c;\u6240\u4ee5\u5f15\u7528\u624d\u6709\u673a\u4f1a\u51a0\u4ee5 &#039;static \u4fee\u9970&#xff0c;\u90a3\u90fd\u6709\u54ea\u4e9b\u503c\u5177\u5907\u8fd9\u79cd\u80fd\u529b\u5462&#xff1f;<\/p>\n<p>1. static \u53d8\u91cf\u7684\u5f15\u7528<\/p>\n<p>\u8fd9\u662f\u6700\u5e38\u89c1\u7684 &#039;static \u5f15\u7528\u7684\u6765\u6e90&#xff1a;<\/p>\n<p><span class=\"token keyword\">static<\/span> <span class=\"token class-name\">X<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">let<\/span> a<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token class-name\">X<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>2. \u5b57\u9762\u91cf\u7684\u5f15\u7528<\/p>\n<p><span class=\"token keyword\">let<\/span> b<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span> <span class=\"token keyword\">str<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token class-name\">N<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">7<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">let<\/span> c<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span> <span class=\"token keyword\">i32<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token class-name\">N<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>3. Box::leak \u6cc4\u6f0f\u7684\u503c<\/p>\n<p><span class=\"token keyword\">let<\/span> d<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">Box<\/span><span class=\"token punctuation\">::<\/span><span class=\"token function\">leak<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Box<\/span><span class=\"token punctuation\">::<\/span><span class=\"token function\">new<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">::<\/span><span class=\"token function\">from<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hello&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>Box::leak() \u51fd\u6570\u4f1a\u6d88\u8017\u6389 Box \u5b9e\u4f8b&#xff0c;\u7136\u540e\u628a\u5b83\u5b58\u653e\u5728\u5806\u4e0a\u7684\u6570\u636e\u6cc4\u6f0f\u51fa\u6765&#xff0c;\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a &#039;static \u5f15\u7528\u6765\u63a5\u4f4f\u8fd9\u4e2a\u6cc4\u6f0f\u51fa\u6765\u7684\u6570\u636e&#xff0c;\u5c31\u50cf\u4e0a\u9762\u793a\u4f8b\u4ee3\u7801\u505a\u7684\u90a3\u6837\u3002\u8fd9\u79cd\u5904\u7406\u65b9\u6cd5\u4e3b\u8981\u7528\u4e8e\u5728\u7a0b\u5e8f\u7684\u5269\u4f59\u751f\u547d\u671f\u5185\u4fdd\u7559\u6570\u636e\u3002<\/p>\n<p>\u793a\u4f8b\u4e2d\u7684 d \u53cd\u800c\u662f\u5bf9 &#039;static \u5f15\u7528\u7684\u4e00\u79cd\u66f4\u6df1\u523b\u7684\u8868\u8fbe&#xff0c;\u4f5c\u4e3a\u4e00\u4e2a &#039;static \u5f15\u7528&#xff0c;\u5b83\u6307\u5411\u7684\u503c\u4e0d\u5728\u6570\u636e\u6bb5&#xff0c;\u6ca1\u6709\u4efb\u4f55 static \u58f0\u660e&#xff0c;\u4f46\u5b83\u4f9d\u7136\u6210\u7acb&#xff01;\u5b83\u6240\u6307\u5411\u7684\u6570\u636e&#xff08;\u5185\u5b58\u4e2d\u7684\u4f4d\u7f6e&#xff09;\u4f1a\u5728\u7a0b\u5e8f\u7ed3\u675f\u524d\u4e00\u76f4\u6709\u6548\u3002<\/p>\n<h3>2.2 \u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f<\/h3>\n<h4>2.2.1 &#039;static \u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f\u7684\u542b\u4e49<\/h4>\n<p>\u5f53 &#039;static \u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f\u65f6&#xff0c;\u5b83\u8868\u8fbe\u7684\u542b\u4e49\u662f&#xff1a;\u8fd9\u4e2a\u7c7b\u578b\u5185\u90e8\u4e0d\u5f97\u542b\u6709\u4efb\u4f55\u5916\u90e8\u5f15\u7528&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff0c;\u8bf4\u5f97\u518d\u5177\u4f53\u4e00\u4e9b\u7684\u8bdd\u5c31\u662f&#xff1a;\u7ed3\u6784\u4f53\u4e0d\u5f97\u542b\u6709\u4efb\u4f55\u5f15\u7528\u7c7b\u578b\u7684\u5b57\u6bb5&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff0c;\u679a\u4e3e\u3001\u5143\u7ec4\u7b49\u540c\u7406\u3002\u8fd9\u91cc\u987a\u5e26\u89e3\u91ca\u4e00\u4e2a\u5076\u5c14\u4f1a\u6709\u4eba\u4f7f\u7528\u7684\u6982\u5ff5&#xff1a;\u77ed\u671f\u501f\u7528\u3001\u77ed\u751f\u547d\u5468\u671f\u5f15\u7528&#xff0c;\u5b83\u4eec\u7684\u610f\u601d\u5c31\u662f&#xff1a;\u9664 &#039;static \u5f15\u7528\u4e4b\u5916\u7684\u6240\u6709\u5f15\u7528&#xff0c;\u56e0\u4e3a\u6bcf\u6b21\u90fd\u8bf4&#xff1a;\u4e0d\u5f97\u542b\u6709\u4efb\u4f55\u5f15\u7528\u7c7b\u578b&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;\u4f1a\u6bd4\u8f83\u9ebb\u70e6&#xff0c;\u6240\u4ee5\u6709\u4eba\u628a\u6392\u9664\u6389 &#039;static \u5f15\u7528\u540e\u7684\u5f15\u7528\u7c7b\u578b\u53eb&#xff1a;\u77ed\u671f\u501f\u7528\u6216\u77ed\u751f\u547d\u5468\u671f\u5f15\u7528&#xff0c;\u6240\u4ee5\u521a\u624d\u7684\u8868\u8ff0\u4e5f\u53ef\u8bf4\u6210\u662f&#xff1a;\u7ed3\u6784\u4f53\u4e0d\u5f97\u542b\u6709\u4efb\u4f55\u77ed\u751f\u547d\u5468\u671f\u5f15\u7528&#xff0c;\u8fd9\u4e2a\u201c\u77ed\u201d\u4e5f\u4e0d\u89c1\u5f97\u771f\u6709\u591a\u77ed&#xff0c;\u53ea\u662f\u76f8\u5bf9\u4e8e &#039;static \u800c\u8a00\u7684\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u5f3a\u5316\u4e24\u4e2a\u77e5\u8bc6\u70b9&#xff1a;\u9996\u5148\u662f\u201c\u7c7b\u578b\u7ea6\u675f\u201d&#xff1a;\u7c7b\u578b\u7ea6\u675f<sup class=\"footnote-ref\">1<\/sup>\u4e3b\u8981\u5305\u62ec&#xff1a;trait bound&#xff08;\u7279\u8d28\u7ea6\u675f&#xff09;\u3001lifetime bound&#xff08;\u751f\u547d\u5468\u671f\u7ea6\u675f&#xff09;\u4e24\u79cd&#xff0c;\u5b83\u4eec\u90fd\u662f\u7528\u6765\u4fee\u9970\u6cdb\u578b\u7684\u201c\u7c7b\u578b\u53c2\u6570\u201d\u7684&#xff0c;\u8bb0\u4f4f&#xff1a;\u6ca1\u6709\u6cdb\u578b\u5c31\u6ca1\u6709\u6240\u8c13\u7684\u201c\u7ea6\u675f\u201d&#xff1b;\u7136\u540e\u662f\u201c\u7c7b\u578b\u201d\u6709\u54ea\u4e9b&#xff1f;\u4e5f\u5c31\u662f\u201c\u7c7b\u578b\u7ea6\u675f\u201d\u90fd\u662f\u4f5c\u7528\u5728\u4ec0\u4e48\u4e0a\u9762&#xff1f;\u6700\u5e38\u89c1\u7684\u5f53\u7136\u662f\u7ed3\u6784\u4f53&#xff01;\u5bf9\u4e8e\u7ed3\u6784\u4f53\u6765\u8bf4&#xff0c;\u5982\u679c\u5b83\u6709 &#039;static \u7ea6\u675f&#xff0c;\u5c31\u662f\u6307\u4e0d\u5141\u8bb8\u5b83\u542b\u6709\u4efb\u4f55\u5f15\u7528\u7c7b\u578b\u7684\u5b57\u6bb5&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff0c;\u5982\u679c\u662f\u679a\u4e3e\u548c\u5143\u7ec4&#xff0c;\u540c\u6837\u662f\u770b\u5b83\u7684\u7ec4\u6210\u5143\u7d20\u91cc\u6709\u6ca1\u6709\u4efb\u4f55\u5f15\u7528\u7c7b\u578b&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff0c;\u6ce8\u610f&#xff1a;&#039;static \u7ea6\u675f\u7684\u68c0\u67e5\u673a\u5236\u662f\u9012\u5f52\u68c0\u67e5\u7c7b\u578b\u4e2d\u7684\u6240\u6709\u5b57\u6bb5&#xff0c;\u5305\u62ec\u5b57\u6bb5\u4e2d\u7684\u5b57\u6bb5&#xff0c;\u53ea\u8981\u53d1\u73b0\u4e00\u4e2a\u5f15\u7528\u7c7b\u578b&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff0c;\u5c31\u4e0d\u6ee1\u8db3&#xff0c;\u4e00\u4e2a\u90fd\u6ca1\u6709\u624d\u6ee1\u8db3\u3002\u53e6\u5916&#xff0c;\u8bb0\u4f4f&#xff1a;trait \u4ece\u6765\u4e0d\u662f\u4e00\u79cd\u7c7b\u578b&#xff0c;\u7c7b\u578b\u7ea6\u675f\u4ece\u6765\u4e0d\u662f\u4f5c\u7528\u5230\u4e00\u4e2a trait \u4e0a&#xff0c;\u800c\u662f\u4f5c\u7528\u5230\u5b83\u7684\u5b9e\u73b0\u8005\u4e0a&#xff0c;\u5373\u4f7f\u89c1\u5230 trait Foo: &#039;static {&#8230;} \u8fd9\u6837\u5199\u6cd5&#xff0c;\u4e5f\u4e0d\u8981\u9519\u8bef\u7684\u8ba4\u4e3a &#039;static \u53ef\u4ee5\u7ea6\u675f trait&#xff0c;\u5b83\u5b9e\u9645\u4e0a\u7ea6\u675f\u7684\u8fd8\u662f Foo \u7684\u5b9e\u73b0\u8005&#xff0c;\u662f\u8981\u6c42\u5b83\u7684\u5b9e\u73b0\u8005\u5185\u90e8\u4e0d\u5f97\u542b\u6709\u4efb\u4f55\u5f15\u7528\u7c7b\u578b\u7684\u5b57\u6bb5\u3002\u4e0b\u9762&#xff0c;\u6211\u4eec\u770b\u4e00\u4e2a\u793a\u4f8b&#xff0c;\u65e2\u7136\u662f\u8981\u5c55\u793a\u7c7b\u578b\u7ea6\u675f&#xff0c;\u90a3\u5fc5\u5b9a\u8981\u6709\u6cdb\u578b&#xff0c;\u6240\u4ee5&#xff0c;\u8fd8\u662f\u8981\u5f15\u5165\u4e00\u4e2a\u6cdb\u578b\u51fd\u6570\u4f5c\u4e3a driver:<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">Owned<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    name<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5b9a\u4e49\u7ed3\u6784\u4f53\u65f6\u53ea\u8981\u51fa\u73b0\u5f15\u7528&#xff0c;\u5982\u679c\u4e0d\u662f &#039;static \u5f15\u7528&#xff0c;\u5fc5\u987b\u8981\u5f15\u5165\u751f\u547d\u5468\u671f\u6807\u6ce8&#xff01; <\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">Borrowed<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    name<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span> <span class=\"token keyword\">str<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">check<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token class-name\">T<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token lifetime-annotation symbol\">&#039;static<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">(<\/span>_<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">T<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">let<\/span> s <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">String<\/span><span class=\"token punctuation\">::<\/span><span class=\"token function\">from<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;hi&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ Owned \u4e0d\u542b\u5f15\u7528&#xff0c;\u6ee1\u8db3&#xff1a;T: &#039;static \u7ea6\u675f<\/span><br \/>\n    <span class=\"token function\">check<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Owned<\/span> <span class=\"token punctuation\">{<\/span> name<span class=\"token punctuation\">:<\/span> s<span class=\"token punctuation\">.<\/span><span class=\"token function\">clone<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u2611    <\/span><br \/>\n    <span class=\"token comment\">\/\/ Borrowed \u542b\u6709\u5f15\u7528&#xff0c;\u4e0d\u6ee1\u8db3&#xff1a;T: &#039;static \u7ea6\u675f<\/span><br \/>\n    <span class=\"token function\">check<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Borrowed<\/span> <span class=\"token punctuation\">{<\/span> name<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span>s <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2612      <\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u6709\u4e9b\u4eba\u4f1a\u5bf9 &#039;static \u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f\u65f6\u7684\u542b\u4e49\u611f\u5230\u56f0\u60d1&#xff0c;\u89c9\u5f97\u6ca1\u6cd5\u628a\u5b83\u672c\u6765\u7684\u8bed\u4e49\u548c\u5bf9\u7c7b\u578b\u7684\u7ea6\u675f\u6548\u679c\u8054\u7cfb\u8d77\u6765&#xff0c;\u6240\u4ee5\u76f4\u63a5\u201c\u6b7b\u8bb0\u786c\u80cc\u201d\u4e86\u5b83\u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f\u65f6\u7684\u542b\u4e49&#xff1a;\u4e0d\u80fd\u542b\u6709\u5916\u90e8\u5f15\u7528\u3002\u5b9e\u9645\u4e0a&#xff0c; &#039;static \u4f5c\u4e3a\u7c7b\u578b\u7ea6\u675f\u65f6\u8868\u8fbe\u51fa\u7684\u8bed\u4e49\u8fd8\u662f\u5f88\u81ea\u7136\u7684&#xff1a; &#039;static \u4fee\u9970\u7684\u662f\u4e00\u4e2a\u7c7b\u578b&#xff0c;\u5957\u7528\u5b83\u7684\u539f\u59cb\u8bed\u4e49\u7684\u8bdd&#xff0c;\u610f\u601d\u662f\u8bf4&#xff1a;\u8fd9\u4e2a\u7c7b\u578b\u53ef\u4ee5\u4e00\u76f4\u6d3b\u5230\u7a0b\u5e8f\u8fd0\u884c\u7ed3\u675f&#xff0c;\u7c7b\u578b\u53c8\u4e0d\u662f\u4e00\u4e2a\u5177\u4f53\u503c&#xff0c;\u672c\u6765\u4e0d\u5c31\u662f\u4e00\u76f4\u5b58\u5728\u5417&#xff1f;\u8fd9\u4e2a\u60f3\u6cd5\u5c31\u88ab\u201c\u60ef\u6027\u601d\u7ef4\u201d\u5e26\u8dd1\u4e86&#xff0c;\u522b\u5fd8\u4e86&#xff1a;\u7c7b\u578b\u91cc\u53ef\u4ee5\u5305\u542b\u5f15\u7528\u5b57\u6bb5&#xff0c;\u6709\u4e86\u5f15\u7528&#xff0c;\u7c7b\u578b\u7684\u751f\u547d\u5468\u671f\u5c31\u4f1a\u5bf9\u5916\u90e8\u7684\u503c\u4ea7\u751f\u7684\u4f9d\u8d56&#xff0c;\u8fd9\u65f6\u5019&#xff0c;\u7c7b\u578b\u5c31\u5fc5\u987b\u6dfb\u52a0\u751f\u547d\u5468\u671f\u6807\u6ce8\u4e86&#xff0c;\u9664\u975e\u4f9d\u8d56\u7684\u662f &#039;static \u5f15\u7528&#xff0c;\u4e5f\u5c31\u662f\u8bf4&#xff1a;\u4ece\u751f\u547d\u5468\u671f\u8fd9\u4e2a\u7ef4\u5ea6\u89c2\u5bdf&#xff0c;\u7c7b\u578b\u53ef\u4ee5\u5206\u6210\u4e24\u79cd&#xff1a;\u4e00\u79cd\u662f\u751f\u547d\u5468\u671f\u4f9d\u8d56\u4e0d\u53d7\u5916\u754c\u5f71\u54cd\u7684&#xff0c;\u53e6\u4e00\u79cd\u662f\u751f\u547d\u5468\u671f\u4f1a\u4f9d\u8d56\u5916\u90e8\u503c\u7684\u751f\u547d\u5468\u671f\u7684&#xff0c;\u5177\u4f53\u5230\u4ee3\u7801\u4e0a\u7684\u8868\u73b0\u5c31\u662f&#xff1a;\u524d\u8005\u53ea\u542b\u6709\u503c\u6216 &#039;static \u5f15\u7528&#xff1b;\u540e\u8005\u5219\u5728\u5b9a\u4e49\u4e2d\u5f15\u5165\u4e86\u5916\u90e8\u5f15\u7528&#xff08;\u5982\u679c\u51fa\u73b0\u5c31\u5fc5\u987b\u8fdb\u884c\u751f\u547d\u5468\u671f\u6807\u6ce8&#xff09;&#xff0c;\u53ea\u662f Rust \u6ca1\u6709\u7ed9\u8fd9\u4e24\u79cd\u7c7b\u578b\u8d77\u8fc7\u6b63\u5f0f\u7684\u79f0\u8c13\u3002\u4f46\u662f&#xff0c;&#039;static \u7ea6\u675f\u521a\u597d\u80fd\u7cbe\u51c6\u5730\u5c06\u8fd9\u4e24\u79cd\u7c7b\u578b\u533a\u5206\u5f00\u4e86&#xff0c;\u6ee1\u8db3 &#039;static \u7ea6\u675f\u7684\u5c31\u662f\u7b2c\u4e00\u79cd\u7c7b\u578b&#xff0c;\u4e0d\u6ee1\u8db3\u7684\u5c31\u662f\u7b2c\u4e8c\u79cd\u7c7b\u578b&#xff0c;\u6240\u4ee5&#xff0c;\u6211\u4eec\u5728\u65e5\u5e38\u8868\u8ff0\u65f6&#xff0c;\u8bf4&#xff1a;\u201c\u4e00\u4e2a\u7c7b\u578b\u662f &#039;static \u7684\u201d\u5c31\u662f\u8bf4\u5b83\u4e0d\u5305\u542b\u5f15\u7528\u7c7b\u578b&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff1b;\u8bf4&#xff1a;\u201c\u4e00\u4e2a\u7c7b\u578b\u4e0d\u662f &#039;static \u7684\u201d\u5c31\u8868\u793a\u5b83\u5185\u90e8\u4e00\u5b9a\u6709\u77ed\u751f\u547d\u5468\u671f\u5f15\u7528\u3002<\/p>\n<h4>2.2.2 \u6ee1\u8db3 &#039;static \u7ea6\u675f\u7684\u7c7b\u578b\u79cd\u7c7b<\/h4>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u518d\u770b\u6ee1\u8db3\u7ea6\u675f\u7684\u5b9e\u73b0\u8005\u8fd9\u4e00\u4fa7&#xff0c;\u6211\u4eec\u8bf4&#xff1a;\u4e00\u4e2a\u7c7b\u578b\u662f\u5426\u6ee1\u8db3 &#039;static \u5c31\u662f\u770b\u5b83\u6709\u6ca1\u6709\u5916\u90e8\u5f15\u7528&#xff0c;\u8fd9\u4e2a\u63cf\u8ff0\u867d\u7136\u6b63\u786e&#xff0c;\u4f46\u4e0d\u591f\u7ec6\u81f4&#xff0c;\u4e00\u4e2a\u7c7b\u578b\u662f\u5426\u542b\u6709\u5916\u90e8\u5f15\u7528\u5e76\u4e0d\u662f\u5355\u5355\u770b\u5b83\u7684\u5b57\u6bb5\u6709\u6ca1\u6709\u5f15\u7528\u7c7b\u578b\u8fd9\u4e48\u7b80\u5355&#xff08;\u5f53\u7136&#xff0c;\u8fd9\u662f\u5176\u4e2d\u4e00\u79cd\u60c5\u5f62&#xff09;&#xff0c;\u6709\u4e24\u65b9\u9762\u7684\u56e0\u7d20\u4f1a\u5f71\u54cd\u6700\u7ec8\u7684\u7ed3\u679c&#xff1a;<\/p>\n<p>\u2460 \u4e00\u4e2a\u7c7b\u578b&#xff0c;\u6bd4\u5982\u4e00\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u5982\u679c\u5f15\u5165\u4e86\u6cdb\u578b&#xff0c;\u90a3\u5b83\u5c31\u4e0d\u662f\u4e00\u4e2a\u5355\u4e00\u7ed3\u6784\u4f53\u4e86&#xff0c;\u800c\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\u201c\u6a21\u677f\u201d&#xff0c;\u6b64\u65f6&#xff0c;\u5b83\u662f\u5426\u6ee1\u8db3 &#039;static \u7ea6\u675f\u5c31\u4e0d\u80fd\u5355\u5355\u770b\u5b83\u81ea\u8eab\u6709\u6ca1\u6709\u5f15\u7528\u5b57\u6bb5\u4e86&#xff0c;\u8fd8\u8981\u770b\u5177\u4f53\u7684\u7c7b\u578b\u53c2\u6570&#xff0c;\u5982\u679c\u5728\u5b9e\u4f8b\u5316\u65f6\u4f20\u5165\u4e86\u5f15\u7528\u7c7b\u578b&#xff0c;\u90a3\u8fd9\u4e2a\u5177\u4f53\u7684\u5b9e\u4f8b\u540c\u6837\u4e5f\u662f\u4e0d\u6ee1\u8db3 &#039;static \u7ea6\u675f\u7684&#xff08;\u53c2\u8003\u4e0b\u9762\u793a\u4f8b\u4e2d\u7684 struct C&#xff09;&#xff1b;<\/p>\n<p>\u2461 \u4e00\u4e2a\u7c7b\u578b&#xff0c;\u6bd4\u5982\u4e00\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u786e\u5b9e\u4f9d\u8d56\u5230\u4e86\u5f15\u7528\u5b57\u6bb5&#xff0c;\u6b64\u65f6\u5fc5\u987b\u5728\u7ed3\u6784\u4f53\u58f0\u660e\u4e0a\u6dfb\u52a0\u751f\u547d\u5468\u671f\u6807\u6ce8&#xff0c;\u4f46\u662f&#xff0c;\u5982\u679c\u5728\u5b9e\u4f8b\u5316\u65f6\u4f20\u5165\u7684\u662f &#039;static \u5f15\u7528&#xff0c;\u53cd\u800c\u53ef\u4ee5\u6ee1\u8db3 &#039;static \u7ea6\u675f&#xff08;\u53c2\u8003\u4e0b\u9762\u793a\u4f8b\u4e2d\u7684 struct D&#xff09;\u3002<\/p>\n<p>\u4ee5\u4e0b\u5217\u4e3e\u4e86\u56db\u79cd\u5178\u578b\u7684\u7c7b\u578b&#xff08;\u7ed3\u6784\u4f53&#xff09;\u5b9a\u4e49&#xff0c;\u6709\u7684\u53ef\u4ee5\u76f4\u63a5\u786e\u5b9a\u662f\u5426\u6ee1\u8db3 &#039;static \u7ea6\u675f&#xff0c;\u6709\u7684\u5219\u662f\u56e0\u4e3a\u5f15\u5165\u4e86\u6cdb\u578b\u8981\u518d\u9012\u8fdb\u4e00\u5c42\u5206\u6790\u6cdb\u578b\u7c7b\u578b\u662f\u5426\u6ee1\u8db3 &#039;static \u7ea6\u675f&#xff0c;\u8fd8\u6709\u7684\u662f\u56e0\u4e3a\u5f15\u5165\u4e86\u751f\u547d\u5468\u671f\u53c2\u6570&#xff0c;\u5982\u679c\u4f20\u5165\u662f &#039;static \u5f15\u7528&#xff0c;\u5c31\u6ee1\u8db3&#xff0c;\u5426\u5219\u5c31\u4e0d\u6ee1\u8db3&#xff1a;<\/p>\n<table>\n<tr>\u60c5\u5f62\u5b9a\u4e49\u662f\u5426\u6ee1\u8db3 &#039;static \u7ea6\u675f<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">1<\/td>\n<td align=\"left\">struct A { x: i32 }<\/td>\n<td align=\"left\">\u603b\u662f<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">2<\/td>\n<td align=\"left\">struct B { s: &amp;&#039;static str }<\/td>\n<td align=\"left\">\u603b\u662f<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">3<\/td>\n<td align=\"left\">struct C { x: T }<\/td>\n<td align=\"left\">\u53d6\u51b3\u4e8e T&#xff0c;\u5982\u679c T \u6ee1\u8db3 &#039;static \u7ea6\u675f&#xff0c;\u5219 C \u6ee1\u8db3&#xff0c;\u53cd\u4e4b\u4ea6\u7136<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">4<\/td>\n<td align=\"left\">struct D&lt;&#039;a&gt; { s: &amp;&#039;a str }<\/td>\n<td align=\"left\">\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u751f\u547d\u5468\u671f&#xff0c;\u5982\u679c\u662f &#039;static&#xff0c;\u5219 D \u6ee1\u8db3&#xff0c;\u5426\u5219\u4e0d\u6ee1\u8db3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.2.3 \u7279\u522b\u573a\u666f&#xff1a;\u4f5c\u4e3a\u95ed\u5305\u7684\u7c7b\u578b\u7ea6\u675f<\/h4>\n<p>\u6211\u89c9\u5f97\u9700\u8981\u7279\u522b\u628a &#039;static \u4f5c\u4e3a\u95ed\u5305\u7684\u7c7b\u578b\u7ea6\u675f\u5355\u72ec\u62ff\u51fa\u6765\u4ecb\u7ecd\u4e00\u4e0b\u3002\u9996\u5148&#xff0c;\u95ed\u5305\u4e5f\u662f\u6709\u7c7b\u578b\u7684&#xff08;Fn\u3001FnMut\u3001FnOnce&#xff09;&#xff0c;\u6240\u4ee5&#xff0c;\u7406\u8bba\u4e0a&#xff0c;&#039;static \u4f5c\u4e3a\u95ed\u5305\u7c7b\u578b\u7ea6\u675f\u548c &#039;static \u4f5c\u4e3a\u666e\u901a\u7c7b\u578b&#xff08;\u6bd4\u5982\u7ed3\u6784\u4f53&#xff09;\u7684\u7ea6\u675f\u5e94\u8be5\u662f\u6ca1\u6709\u5206\u522b\u7684&#xff0c;\u4f46\u662f\u95ed\u5305\u6bd5\u7adf\u4e0d\u662f\u7ed3\u6784\u4f53&#xff0c;&#039;static \u80fd\u7ea6\u675f\u5230\u95ed\u5305\u7684\u4ec0\u4e48\u5462&#xff1f;\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u95ee\u9898&#xff0c;\u5982\u679c\u627e\u5230\u5173\u952e\u8054\u7cfb&#xff0c;\u7406\u89e3\u8d77\u6765\u5c31\u4f1a\u975e\u5e38\u8f7b\u677e\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053&#xff0c;\u95ed\u5305\u90fd\u4f1a\u88ab\u7f16\u8bd1\u5668\u81ea\u52a8\u7f16\u8bd1\u6210\u533f\u540d\u7684\u7ed3\u6784\u4f53&#xff0c;\u5b83\u6240\u6355\u83b7\u7684\u5916\u90e8\u503c\u6216\u5f15\u7528\u90fd\u662f\u8fd9\u4e2a\u7ed3\u6784\u4f53\u4e2d\u7684\u5b57\u6bb5\u3002\u8fd9\u5c31\u548c &#039;static \u4f5c\u4e3a\u7ed3\u6784\u4f53\u7684\u7c7b\u578b\u7ea6\u675f\u80fd\u5bf9\u9f50\u4e86&#xff01;\u5f53 &#039;static \u4f5c\u4e3a\u95ed\u5305\u7684\u7c7b\u578b\u7ea6\u675f\u65f6&#xff08;\u4e5f\u5c31\u662f\u51fa\u73b0\u5728 T: Fn()\/FnMut()\/FnOnce() &#043; &#039;static \u8fd9\u79cd\u4f4d\u7f6e\u4e0a\u65f6&#xff09;&#xff0c;\u5b83\u5b9e\u9645\u4e0a\u7ea6\u675f\u7684\u662f&#xff1a;\u95ed\u5305\u4e0d\u5f97\u6355\u83b7\u5916\u90e8\u7684\u5f15\u7528&#xff08;&#039;static \u5f15\u7528\u9664\u5916&#xff09;&#xff01;\u8fd9\u79cd\u60c5\u5f62\u6709\u4e00\u4e2a\u6700\u5e38\u89c1\u7684\u4f8b\u5b50&#xff0c;\u5c31\u662f thread::spawn() \u9700\u8981\u7684\u95ed\u5305&#xff0c;\u5b83\u7684\u7c7b\u578b\u7ea6\u675f\u5c31\u662f&#xff1a;F: FnOnce() -&gt; T &#043; Send &#043; &#039;static&#xff0c;\u5982\u679c\u4f60\u4f20\u7ed9 thread::spawn() \u7684\u95ed\u5305\u4f9d\u8d56\u5230\u4e86\u4e00\u4e2a\u5916\u90e8\u7684\u5f15\u7528&#xff0c;\u7f16\u8bd1\u4f1a\u62a5\u9519&#xff0c;\u4e00\u822c\u7684\u89e3\u51b3\u65b9\u6cd5\u5c31\u662f\u4f7f\u7528 move \u5173\u952e\u5b57\u628a\u5f15\u7528\u7684\u503c\u76f4\u63a5 move \u8fdb\u95ed\u5305\u3002<\/p>\n<h3>2.4 \u51fa\u73b0\u5728 supertrait \u7684\u4f4d\u7f6e\u4e0a<\/h3>\n<p>&#039;static \u8fd8\u53ef\u4ee5\u51fa\u73b0\u5728 supertrait \u7684\u4f4d\u7f6e\u4e0a&#xff0c;\u4f46\u8fd9\u4e2a\u63cf\u8ff0\u672c\u8eab\u5c31\u6709\u4e00\u5b9a\u6b3a\u9a97\u6027&#xff0c;\u6c38\u8fdc\u4e0d\u8981\u628a &#039;static \u5f53\u6210 trait&#xff01;\u51fa\u73b0\u5728 supertrait \u4f4d\u7f6e\u4e0a\u7684 &#039;static \u5e76\u4e0d\u662f\u771f\u5f97 supertrait&#xff0c;\u5176\u5b9e\u8fd8\u662f\u7c7b\u578b\u7ea6\u675f&#xff0c;\u7ea6\u675f\u662f\u7684 self&#xff0c;\u4e5f\u5c31\u662f trait \u7684\u5b9e\u73b0\u8005\u3002\u770b\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50&#xff1a;<\/p>\n<p><span class=\"token keyword\">trait<\/span> <span class=\"token type-definition class-name\">Plugin<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token lifetime-annotation symbol\">&#039;static<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span><span class=\"token keyword\">self<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">A<\/span> <span class=\"token punctuation\">{<\/span> name<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">impl<\/span> <span class=\"token class-name\">Plugin<\/span> <span class=\"token keyword\">for<\/span> <span class=\"token class-name\">A<\/span> <span class=\"token punctuation\">{<\/span>             <span class=\"token comment\">\/\/ A \u4e0d\u542b\u5f15\u7528\u5b57\u6bb5&#xff0c;\u53ef\u7f16\u8bd1<\/span><br \/>\n    <span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span><span class=\"token keyword\">self<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token macro property\">println!<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;{}&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">self<\/span><span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">B<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span> src<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span> <span class=\"token keyword\">str<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">impl<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token class-name\">Plugin<\/span> <span class=\"token keyword\">for<\/span> <span class=\"token class-name\">B<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span>     <span class=\"token comment\">\/\/ B \u542b\u6709\u5f15\u7528\u5b57\u6bb5&#xff0c;\u65e0\u6cd5\u5b9e\u73b0 Plugin&#xff0c;\u7f16\u8bd1\u9519\u8bef<\/span><br \/>\n    <span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span><span class=\"token keyword\">self<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token macro property\">println!<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;{}&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">self<\/span><span class=\"token punctuation\">.<\/span>src<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h3>2.5 \u4f5c\u4e3a\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570\u7684\u4e00\u4e2a\u201c\u5e38\u91cf\u201d<\/h3>\n<p>&#039;static \u6700\u540e\u4e00\u79cd\u7528\u6cd5\u5c31\u662f\u4f5c\u4e3a\u751f\u547d\u5468\u671f\u53c2\u6570\u7684\u4e00\u4e2a\u201c\u5177\u4f53\u7c7b\u578b\u201d\u66ff\u6362\u5728\u6cdb\u578b\u4e2d\u58f0\u660e\u7684\u4e00\u4e2a\u751f\u547d\u5468\u671f\u3002&#039;static \u662f\u552f\u4e00\u6709\u540d\u5b57\u7684\u5177\u4f53\u751f\u547d\u5468\u671f&#xff0c;\u53ef\u4ee5\u89c6\u4f5c &#039;a \u8fd9\u79cd\u751f\u547d\u5468\u671f\u53c2\u6570\u7684\u4e00\u4e2a\u201c\u5e38\u91cf\u201d&#xff0c;\u5b9e\u9645\u4e0a&#xff0c;&#039;static \u7684\u8fd9\u79cd\u7528\u6cd5\u6211\u4eec\u5728 2.2.2 \u8282\u5df2\u7ecf\u4ecb\u7ecd\u5230\u4e86&#xff0c;\u5c31\u662f\u9488\u5bf9 struct D&lt;&#039;a&gt; { s: &amp;&#039;a str } \u8fd9\u79cd \u5e26\u751f\u547d\u5468\u671f\u6807\u6ce8\u7684\u7ed3\u6784\u4f53&#xff0c;\u5f53\u6211\u4eec\u521b\u5efa\u4e00\u4e2a D \u7684\u5b9e\u4f8b\u65f6&#xff0c;\u4f20\u5165\u7684\u5f15\u7528\u4f1a\u628a\u751f\u547d\u5468\u671f\u7ea6\u675f\u5173\u7cfb\u5e26\u5165\u5230\u8fd9\u4e2a\u5b9e\u4f8b\u4e2d\u3002\u8fd9\u91cc\u6709\u4e00\u79cd\u7279\u6b8a\u573a\u666f&#xff1a;\u6211\u4eec\u53ef\u4ee5\u4f20\u5165 &#039;static \u5f97\u5230\u4e00\u4e2a\u4e0d\u4f9d\u8d56\u5916\u90e8\u5f15\u7528\u6216\u8005\u53ea\u6709 &#039;static \u5f15\u7528\u7684\u5177\u4f53\u7c7b\u578b\u3002\u4e0b\u9762&#xff0c;\u5217\u4e3e\u4e86\u4e09\u79cd\u5e38\u89c1\u7684\u51fa\u73b0\u5f62\u5f0f&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span> s<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span> <span class=\"token keyword\">str<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">f<\/span><span class=\"token punctuation\">(<\/span>d<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token punctuation\">&#8230;<\/span> <span class=\"token punctuation\">}<\/span>        <span class=\"token comment\">\/\/ \u2611 \u4f5c\u4e3a\u53c2\u6570<\/span><br \/>\n<span class=\"token keyword\">type<\/span> <span class=\"token type-definition class-name\">StaticD<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token punctuation\">;<\/span>       <span class=\"token comment\">\/\/ \u2611 \u7c7b\u578b\u522b\u540d<\/span><br \/>\n<span class=\"token keyword\">let<\/span> d<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">D<\/span> <span class=\"token punctuation\">{<\/span> s<span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;hi&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u2611 \u4f5c\u4e3a\u53d8\u91cf<\/span><\/p>\n<p>\u8fd9\u91cc&#xff0c;\u6211\u4eec\u8981\u6f84\u6e05\u4e24\u4e2a\u6982\u5ff5&#xff1a;\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570\u4e0e\u751f\u547d\u5468\u671f\u6807\u6ce8\u3002\u5bf9\u4e8e struct D&lt;&#039;a&gt; { s: &amp;&#039;a str } \u800c\u8a00&#xff0c;\u5b83\u786e\u5b9e\u6709\u201c\u6cdb\u578b\u201d\u7684\u4e00\u9762&#xff0c;\u56e0\u4e3a\u5b83\u4f7f\u7528 &lt;&gt; \u58f0\u660e\u4e86\u6cdb\u578b\u53c2\u6570&#xff0c;\u800c\u91cc\u9762\u7684\u8fd9\u4e2a** &#039;a \u53eb\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570<sup class=\"footnote-ref\">2<\/sup>&#xff0c;\u7b80\u79f0&#xff1a;\u751f\u547d\u5468\u671f\u53c2\u6570&#xff0c;\u4f46\u5b83\u540c\u65f6\u4e5f\u662f\u751f\u547d\u5468\u671f\u6807\u6ce8&#xff0c;\u4e24\u79cd\u542b\u4e49\u5e76\u4e0d\u51b2\u7a81&#xff0c;\u5e76\u4e14\u4e5f\u5f88\u96be\u5265\u79bb\u5f00**\u3002<\/p>\n<p>\u901a\u5e38&#xff0c;\u6211\u662f\u5c06 &#039;a \u770b\u4f5c\u4e00\u79cd\u751f\u547d\u5468\u671f\u6807\u6ce8&#xff0c;\u5f88\u5c11\u4f1a\u5c06\u5176\u770b\u4f5c\u4e00\u4e2a\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570&#xff0c;\u56e0\u4e3a&#xff1a;\u5f53 &#039;a \u4f5c\u4e3a\u751f\u547d\u5468\u671f\u53c2\u6570\u65f6&#xff0c;\u5b83\u7684\u201c\u5177\u4f53\u503c\u201d\u662f\u5728\u5b9e\u4f8b\u5316\u7ed3\u6784\u4f53\u65f6&#xff0c;\u7531\u7f16\u8bd1\u5668\u6839\u636e\u4f20\u5165\u7684\u5f15\u7528\u81ea\u52a8\u63a8\u65ad\u51fa\u6765\u7684&#xff0c;\u5b83\u786e\u5b9e\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u751f\u547d\u5468\u671f\u7684\u201c\u503c\u201d&#xff0c;\u8fd9\u662f &#039;a \u5177\u6709\u201c\u6cdb\u578b\u201d\u610f\u5473\u7684\u539f\u56e0&#xff0c;\u4f46\u662f&#xff0c;\u8fd9\u4e2a\u201c\u503c\u201d\u4f60\u662f\u5199\u4e0d\u51fa\u6765\u7684&#xff08;\u4e5f\u4e0d\u9700\u8981\u5199\u51fa\u6765&#xff09;&#xff0c;\u63d0\u4f9b\u8fd9\u4e2a\u503c\u7684\u65b9\u5f0f\u662f\u5728\u8981\u5173\u8054\u7684\u5f15\u7528\u5b57\u6bb5\u4e0a\u6dfb\u52a0\u6807\u6ce8&#xff0c;\u7136\u540e\u8ba9\u7f16\u8bd1\u5668\u53bb\u63a8\u65ad\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u5728\u7edd\u5927\u591a\u6570\u60c5\u51b5\u4e0b&#xff0c;\u6211\u4eec\u662f\u4f53\u4f1a\u4e0d\u5230 &#039;a \u4f5c\u4e3a\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570\u7684\u201c\u610f\u4e49\u201d&#xff0c;\u6839\u672c\u539f\u56e0\u5c31\u662f&#xff0c;\u6211\u4eec\u51e0\u4e4e\u5199\u4e0d\u51fa\u4e00\u79cd\u5177\u4f53\u7684\u751f\u547d\u5468\u671f\u7684\u201c\u503c\u201d&#xff0c;\u5168\u90fd\u662f\u9760\u5b83\u4f5c\u4e3a\u751f\u547d\u5468\u671f\u6807\u6ce8\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u63a8\u65ad\u7684&#xff0c;&#039;a \u4f5c\u4e3a\u6cdb\u578b\u53c2\u6570\u7684\u90a3\u4e00\u9762\u5b8c\u5168\u88ab\u906e\u6321\u4e86\u3002\u5982\u679c\u6211\u4eec\u80fd\u660e\u786e\u5730\u5199\u51fa\u4e00\u79cd\u5177\u4f53\u7684\u751f\u547d\u5468\u671f&#xff0c;\u5c31\u53ef\u4ee5\u770b\u5230\u5b83\u4f5c\u4e3a\u201c\u751f\u547d\u5468\u671f\u6cdb\u578b\u53c2\u6570\u201d\u7684\u4e00\u9762&#xff0c;\u6709\u80fd\u5199\u51fa\u6765\u7684\u5177\u4f53\u7684\u751f\u547d\u5468\u671f\u5417&#xff1f;\u6709\u4e14\u53ea\u6709\u4e00\u4e2a&#xff0c;\u5c31\u662f &#039;static&#xff01;\u8fd9\u5c31\u662f\u6211\u4eec\u80fd\u770b\u5230\u7684 &lt;&#039;a&gt; \u6700\u50cf\u4e00\u4e2a\u6cdb\u578b\u53c2\u6570\u800c\u4e0d\u662f\u751f\u547d\u5468\u671f\u7ea6\u675f\u7684\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token type-definition class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span> s<span class=\"token punctuation\">:<\/span> <span class=\"token operator\">&amp;<\/span><span class=\"token lifetime-annotation symbol\">&#039;a<\/span> <span class=\"token keyword\">str<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">let<\/span> d<span class=\"token punctuation\">:<\/span> <span class=\"token class-name\">D<\/span><span class=\"token operator\">&lt;<\/span><span class=\"token lifetime-annotation symbol\">&#039;static<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">D<\/span> <span class=\"token punctuation\">{<\/span> s<span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;hi&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<hr class=\"footnotes-sep\" \/>\n<li id=\"fn1\" class=\"footnote-item\">\n<p>\u5176\u5b9e\u662f\u6709\u4e09\u79cd&#xff0c;\u8fd8\u6709\u4e00\u79cd\u53eb outlives bound&#xff0c;\u6ca1\u6709\u5408\u9002\u7684\u4e2d\u6587\u8bd1\u540d&#xff0c;outlives \u610f\u4e3a&#xff1a;\u6bd4\u2026\u6d3b\u5f97\u4e45\u3002\u5178\u578b\u7684 outlives bound \u5199\u4f5c &#039;a: &#039;b&#xff0c;\u8bfb\u4f5c \u201ca outlives &#039;b\u201d&#xff0c;\u5b83\u7684\u610f\u601d\u662f&#xff1a; &#039;a: &#039;b &#039;a \u81f3\u5c11\u6d3b\u5f97\u8ddf &#039;b \u4e00\u6837\u4e45\u3002\u66f4\u591a\u4fe1\u606f\u53c2\u8003&#xff1a;https:\/\/nomicon.purewhite.io\/dropck.html \u21a9\ufe0e<\/p>\n<\/li>\n<li id=\"fn2\" class=\"footnote-item\">\n<p>Generic Parameter&#xff08;\u6cdb\u578b\u53c2\u6570&#xff09;\u5305\u542b\u4e09\u7c7b&#xff1a;Type Parameter&#xff08;T&#xff09;\u3001Lifetime Parameter&#xff08;&#039;a&#xff09;\u3001Const Parameter&#xff08;const N: usize&#xff09;\u3002\u751f\u547d\u5468\u671f\u53c2\u6570\u662f\u6cdb\u578b\u53c2\u6570\u7684\u4e00\u79cd \u21a9\ufe0e<\/p>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>static \u751f\u547d\u5468\u671f\u7ea6\u675f\u603b\u7ed9\u4eba\u4e00\u79cd\u4e0d\u597d\u62ff\u634f\u7684\u611f\u89c9&#xff0c;\u56e0\u4e3a\u5b83\u51fa\u73b0\u5728\u4e0d\u540c\u4f4d\u7f6e\u4e0a\u65f6\u542b\u4e49\u4e5f\u4f1a\u6709\u6240\u4e0d\u540c&#xff0c;\u9700\u8981\u4ed4\u7ec6\u7504\u522b\u3002\u6b64\u5916&#xff0c;\u5b83\u8fd8\u603b\u4f1a\u548c\u5176\u4ed6\u4e00\u4e9b\u673a\u5236\u5173\u8054\u7740\u4e00\u8d77\u51fa\u73b0&#xff0c;\u6bd4\u5982\u95ed\u5305\u3001Fn trait\u3001\u751f\u547d\u5468\u671f\u7ea6\u675f\u4ee5\u53ca\u591a\u7ebf\u7a0b\u573a\u666f&#xff0c;\u8fd9\u4f1a\u589e\u52a0\u7406\u89e3\u7684\u56f0\u96be\u5ea6&#xff0c;\u6240\u4ee5&#xff0c;\u5bf9 static \u611f\u5230\u56f0\u60d1\u662f\u6b63\u5e38\u7684\u3002\u672c\u6587\u4f1a\u5e26\u9886\u5927\u5bb6\u5168\u9762\u4e86\u89e3\u4e00\u4e0b static \u751f\u547d\u5468\u671f\u7ea6\u675f\u3002\u672c\u6587\u539f\u6587\u94fe\u63a5&#xff1a;https:\/\/laure<\/p>\n","protected":false},"author":2,"featured_media":107298,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12174,12176,9882,12175,206],"topic":[],"class_list":["post-107299","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-static","tag-12176","tag-9882","tag-12175","tag-rust"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/107299.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"static \u751f\u547d\u5468\u671f\u7ea6\u675f\u603b\u7ed9\u4eba\u4e00\u79cd\u4e0d\u597d\u62ff\u634f\u7684\u611f\u89c9&#xff0c;\u56e0\u4e3a\u5b83\u51fa\u73b0\u5728\u4e0d\u540c\u4f4d\u7f6e\u4e0a\u65f6\u542b\u4e49\u4e5f\u4f1a\u6709\u6240\u4e0d\u540c&#xff0c;\u9700\u8981\u4ed4\u7ec6\u7504\u522b\u3002\u6b64\u5916&#xff0c;\u5b83\u8fd8\u603b\u4f1a\u548c\u5176\u4ed6\u4e00\u4e9b\u673a\u5236\u5173\u8054\u7740\u4e00\u8d77\u51fa\u73b0&#xff0c;\u6bd4\u5982\u95ed\u5305\u3001Fn trait\u3001\u751f\u547d\u5468\u671f\u7ea6\u675f\u4ee5\u53ca\u591a\u7ebf\u7a0b\u573a\u666f&#xff0c;\u8fd9\u4f1a\u589e\u52a0\u7406\u89e3\u7684\u56f0\u96be\u5ea6&#xff0c;\u6240\u4ee5&#xff0c;\u5bf9 static \u611f\u5230\u56f0\u60d1\u662f\u6b63\u5e38\u7684\u3002\u672c\u6587\u4f1a\u5e26\u9886\u5927\u5bb6\u5168\u9762\u4e86\u89e3\u4e00\u4e0b static \u751f\u547d\u5468\u671f\u7ea6\u675f\u3002\u672c\u6587\u539f\u6587\u94fe\u63a5&#xff1a;https:\/\/laure\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/107299.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-19T02:08:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260919020843-6aadeeab8b5b5.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/107299.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/107299.html\",\"name\":\"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-19T02:08:45+00:00\",\"dateModified\":\"2026-09-19T02:08:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/107299.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/107299.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/107299.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/107299.html","og_locale":"zh_CN","og_type":"article","og_title":"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"static \u751f\u547d\u5468\u671f\u7ea6\u675f\u603b\u7ed9\u4eba\u4e00\u79cd\u4e0d\u597d\u62ff\u634f\u7684\u611f\u89c9&#xff0c;\u56e0\u4e3a\u5b83\u51fa\u73b0\u5728\u4e0d\u540c\u4f4d\u7f6e\u4e0a\u65f6\u542b\u4e49\u4e5f\u4f1a\u6709\u6240\u4e0d\u540c&#xff0c;\u9700\u8981\u4ed4\u7ec6\u7504\u522b\u3002\u6b64\u5916&#xff0c;\u5b83\u8fd8\u603b\u4f1a\u548c\u5176\u4ed6\u4e00\u4e9b\u673a\u5236\u5173\u8054\u7740\u4e00\u8d77\u51fa\u73b0&#xff0c;\u6bd4\u5982\u95ed\u5305\u3001Fn trait\u3001\u751f\u547d\u5468\u671f\u7ea6\u675f\u4ee5\u53ca\u591a\u7ebf\u7a0b\u573a\u666f&#xff0c;\u8fd9\u4f1a\u589e\u52a0\u7406\u89e3\u7684\u56f0\u96be\u5ea6&#xff0c;\u6240\u4ee5&#xff0c;\u5bf9 static \u611f\u5230\u56f0\u60d1\u662f\u6b63\u5e38\u7684\u3002\u672c\u6587\u4f1a\u5e26\u9886\u5927\u5bb6\u5168\u9762\u4e86\u89e3\u4e00\u4e0b static \u751f\u547d\u5468\u671f\u7ea6\u675f\u3002\u672c\u6587\u539f\u6587\u94fe\u63a5&#xff1a;https:\/\/laure","og_url":"https:\/\/www.wsisp.com\/helps\/107299.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-19T02:08:45+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260919020843-6aadeeab8b5b5.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/107299.html","url":"https:\/\/www.wsisp.com\/helps\/107299.html","name":"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-19T02:08:45+00:00","dateModified":"2026-09-19T02:08:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/107299.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/107299.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/107299.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u56f0\u60d1\u662f\u6b63\u5e38\u7684,\u2018static \u751f\u547d\u5468\u671f\u7ea6\u675f\u672c\u6765\u5c31\u4e0d\u7b80\u5355"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/107299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=107299"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/107299\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/107298"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=107299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=107299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=107299"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=107299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}