{"id":453967,"date":"2025-04-01T15:09:26","date_gmt":"2025-04-01T15:09:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=453967"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=453967","title":{"rendered":"<span>const fn \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c88\/5f7\/1d6\/c885f71d6c9bdff85e1081bd6b377c53.jpg\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c88\/5f7\/1d6\/c885f71d6c9bdff85e1081bd6b377c53.jpg\" data-blurred=\"true\"\/><\/figure>\n<hr\/>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p><code>const fn<\/code> \u0432 Rust \u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0446\u0438\u043a\u043b\u044b, \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043c\u0430\u0442\u0447\u0438\u043d\u0433, \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0438 \u0434\u0430\u0436\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u2014 \u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h3>\u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u2014 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430. \u0422\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e n!, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0441\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0435\u0439. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0441\u0430\u043c\u043e \u0447\u0438\u0441\u043b\u043e, \u0430 \u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>const fn<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b <strong>\u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> \u2014 \u0438 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u043d\u0438 \u0431\u0430\u0439\u0442\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 runtime.<\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"rust\">\/\/ \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u2014 \u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438! const fn factorial(n: u64) -&gt; u64 {     let mut result = 1;     let mut i = 1;     while i &lt;= n {         result *= i;         i += 1;     }     result }  \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 runtime const FACT_5: u64 = factorial(5);  fn main() {     println!(\"5! = {}\", FACT_5); \/\/ \u0412\u044b\u0432\u043e\u0434: 120 }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>factorial <\/code>\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>const fn<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442, \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 const-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 factorial(5) \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 120 <strong>\u0443\u0436\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/strong>, \u0438 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0448\u0438\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b 120.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0435\u0437 const fn, \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0431\u044b \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b (\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e),<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0432 <code>main()<\/code> (\u0438 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b),<\/p>\n<\/li>\n<li>\n<p>\u0438\u043b\u0438, \u0447\u0442\u043e \u0435\u0449\u0451 \u0445\u0443\u0436\u0435, \u0442\u0430\u0449\u0438\u0442\u044c \u044d\u0442\u043e \u0432 <code>lazy_static!<\/code> \u0438\u043b\u0438 <code>once_cell<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0430\u043a \u2014 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0447\u0438\u0441\u0442\u043e \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0433\u043e\u0442\u043e\u0432\u043e.<\/p>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0447\u0435\u043c\u0443-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u043c\u0443. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0434\u0440\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430 runtime \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0430\u0434\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<pre><code class=\"rust\">\/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430: a0 + a1*x + a2*x^2 + ... + an*x^n const fn eval_poly(coeffs: &amp;[i32], x: i32) -&gt; i32 {     let mut result = 0;     let mut pow = 1;     let mut i = 0;     while i &lt; coeffs.len() {         result += coeffs[i] * pow;         pow *= x;         i += 1;     }     result }  const COEFFS: &amp;[i32] = &amp;[3, 2, 5]; \/\/ \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0438\u043d\u043e\u043c: 3 + 2*x + 5*x^2 const VALUE: i32 = eval_poly(COEFFS, 2); \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435: 3 + 2*2 + 5*2^2 = 3 + 4 + 20 = 27  fn main() {     println!(\"\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430: {}\", VALUE); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>eval_poly<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>const fn<\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0440\u0435\u0437 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>x<\/code>, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 <code>result = 0<\/code> \u0438 <code>pow = 1<\/code> (\u0433\u0434\u0435 pow \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c x), \u0437\u0430\u0442\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 <code>while <\/code>\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 <code>pow<\/code>, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <code>pow<\/code>, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u0435\u0433\u043e \u043d\u0430 <code>x<\/code>, \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0443 \u0432\u0441\u0435\u0445 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>COEFFS <\/code>\u043a\u0430\u043a <code>[3, 2, 5]<\/code> (\u043f\u043e\u043b\u0438\u043d\u043e\u043c <img decoding=\"async\" class=\"formula inline\" source=\"3+2x+5x\u00b2\" alt=\"3+2x+5x\u00b2\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c\/c2\/c23\/c2338029a3ba371c74e7d298a5e6b2b8.svg\" width=\"auto\" height=\"auto\"\/>) \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>const VALUE: i32 = eval_poly(COEFFS, 2)<\/code>, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 27. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f runtime \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u0442\u0440\u043e\u043a<\/h3>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 CSV, JSON \u0438\u043b\u0438 INI? \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. <\/p>\n<h4>CSV-\u043f\u0430\u0440\u0441\u0435\u0440<\/h4>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>Rust,Const,Cats<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0435\u0451 \u0432 runtime, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0435\u0451 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f const fn. <\/p>\n<pre><code class=\"rust\">\/\/ \u041f\u0440\u043e\u0441\u0442\u043e\u0439 CSV-\u043f\u0430\u0440\u0441\u0435\u0440, \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 3 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 const fn parse_csv(input: &amp;str) -&gt; [&amp;str; 3] {     let bytes = input.as_bytes();     let mut result: [&amp;str; 3] = [\"\"; 3];     let mut start = 0;     let mut idx = 0;     let mut i = 0;     while i &lt;= bytes.len() {         if i == bytes.len() || bytes[i] == b',' {             \/\/ Unsafe \u0442\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 CSV \u2013 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 UTF-8.             result[idx] = unsafe { std::str::from_utf8_unchecked(&amp;bytes[start..i]) };             idx += 1;             start = i + 1;         }         i += 1;     }     result }  const CSV_DATA: &amp;str = \"Rust,Const,Cats\"; const PARSED_CSV: [&amp;str; 3] = parse_csv(CSV_DATA);  fn main() {     for field in PARSED_CSV.iter() {         println!(\"\u041f\u043e\u043b\u0435: {}\", field);     } }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>input.as_bytes()<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0437\u0430\u043f\u044f\u0442\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a b&#8217;,&#8217;), \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432 result \u0438\u0437 \u0442\u0440\u0451\u0445 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438; \u0434\u0430\u043b\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0446\u0438\u043a\u043b while, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0431\u0430\u0439\u0442\u0430\u043c, \u0438 \u0435\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0430\u0432\u0435\u043d \u0434\u043b\u0438\u043d\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u044f\u0442\u0430\u044f, \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0441 start \u0434\u043e i \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0435\u0433\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 <code>unsafe { std::str::from_utf8_unchecked(...) }<\/code> (\u0442.\u043a \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 UTF-8, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f const-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430), \u0438 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f (<code>start = i + 1<\/code>) \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a <code>idx<\/code>.  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0432\u0441\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432\u044b\u0432\u043e\u0434 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. <\/p>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u0435\u0439\u0441\u0443 \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0433\u0434\u0435-\u0442\u043e \u0432 runtime, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e const fn \u0438 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct Config {     host: &amp;'static str,     port: u16,     use_ssl: bool, }  const fn create_config() -&gt; Config {     Config {         host: \"localhost\",         port: 8080,         use_ssl: false,     } }  const CONFIG: Config = create_config();  fn main() {     println!(\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f: {:?}\", CONFIG); }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Config<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (\u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430, \u043f\u043e\u0440\u0442 \u0438 \u0444\u043b\u0430\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SSL), \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>#[derive(Debug)]<\/code> \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0451 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435; \u0437\u0430\u0442\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f<code> create_config<\/code>, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a <code>const fn<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 Config \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 <code>create_config()<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 main \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430.  <\/p>\n<h3>\u041c\u0438\u043d\u0438-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 Rust <strong>\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438<\/strong> \u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<pre><code class=\"rust\">\/\/ \u041c\u0438\u043d\u0438-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 + \u0438 - \/\/ \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440\u044b \u0438 \u0437\u043d\u0430\u043a\u0438 +\/-, \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432, \u0431\u0435\u0437 \u0441\u043a\u043e\u0431\u043e\u043a const fn eval_expr(expr: &amp;str) -&gt; i32 {     let bytes = expr.as_bytes();     let mut i = 0;     let mut current_number = 0;     let mut result = 0;     let mut current_sign = 1;     while i &lt; bytes.len() {         let c = bytes[i];         if c &gt;= b'0' &amp;&amp; c &lt;= b'9' {             current_number = current_number * 10 + (c - b'0') as i32;         } else {             result += current_sign * current_number;             current_number = 0;             current_sign = if c == b'+' { 1 } else { -1 };         }         i += 1;     }     result + current_sign * current_number }  const EXPR: &amp;str = \"12+34-5+6\"; const EVAL_RESULT: i32 = eval_expr(EXPR);  fn main() {     println!(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f {}: {}\", EXPR, EVAL_RESULT); }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as_bytes()<\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u0440\u0443\u0447\u043d\u0443\u044e (\u0430 \u0432 <code>const fn<\/code> \u043d\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0438\u043f\u0430 <code>.split()<\/code> \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439). \u041f\u0440\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0430\u0439\u0442\u0430\u043c, \u0435\u0441\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0446\u0438\u0444\u0440\u0430 (\u043e\u0442 b&#8217;0&#8242; \u0434\u043e b&#8217;9&#8242;), \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>current_number<\/code>, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 10 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u0443\u044e \u0446\u0438\u0444\u0440\u0443.<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 (+ \u0438\u043b\u0438 -), \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f: \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 <code>result <\/code>\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c <code>current_number<\/code> \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u043a \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c, \u043e\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a <code>result <\/code>\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0447\u0442\u043e \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0431\u0438\u043d\u0430\u0440\u044c, \u0430 \u0432 runtime \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0411\u0435\u0437 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0431\u0435\u0437 eval, \u0431\u0435\u0437 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439.<\/p>\n<h3>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438 \u0446\u0438\u043a\u043b\u044b \u0432 const \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 const \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. <\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct SimpleConfig {     host: &amp;'static str,     port: u16, }  \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e JSON \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. const fn parse_simple_json(json: &amp;str) -&gt; SimpleConfig {     \/\/ \u0416\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2013 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430     let host_start = 10;     let host_end = 19;     let port_start = 30;     let port_end = 34;      let host = unsafe { std::str::from_utf8_unchecked(json.as_bytes().get(host_start..host_end).unwrap()) };      let mut port = 0u16;     let mut i = port_start;     while i &lt; port_end {         let digit = (json.as_bytes()[i] - b'0') as u16;         port = port * 10 + digit;         i += 1;     }      SimpleConfig { host, port } }  const JSON_STR: &amp;str = r#\"{\"host\": \"localhost\", \"port\": 8080}\"#; const CONFIG_JSON: SimpleConfig = parse_simple_json(JSON_STR);  fn main() {     println!(\"\u041f\u0430\u0440\u0441\u0438\u043d\u0433 JSON: {:?}\", CONFIG_JSON); }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/h3>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, JSON-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"json\">{\"host\": \"localhost\", \"port\": 8080}<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043a\u0443\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u043e \u0438\u0434\u0435\u044f \u044f\u0441\u043d\u0430.<\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct SimpleConfig {     host: &amp;'static str,     port: u16, }  \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e JSON \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. const fn parse_simple_json(json: &amp;str) -&gt; SimpleConfig {     \/\/ \u0416\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2013 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430     let host_start = 10;     let host_end = 19;     let port_start = 30;     let port_end = 34;      let host = unsafe { std::str::from_utf8_unchecked(json.as_bytes().get(host_start..host_end).unwrap()) };      let mut port = 0u16;     let mut i = port_start;     while i &lt; port_end {         let digit = (json.as_bytes()[i] - b'0') as u16;         port = port * 10 + digit;         i += 1;     }      SimpleConfig { host, port } }  const JSON_STR: &amp;str = r#\"{\"host\": \"localhost\", \"port\": 8080}\"#; const CONFIG_JSON: SimpleConfig = parse_simple_json(JSON_STR);  fn main() {     println!(\"\u041f\u0430\u0440\u0441\u0438\u043d\u0433 JSON: {:?}\", CONFIG_JSON); }<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 INI-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct IniConfig {     host: &amp;'static str,     port: u16, }  const fn parse_ini(input: &amp;str) -&gt; IniConfig {     \/\/ \u0424\u043e\u0440\u043c\u0430\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d:     \/\/ [server]     \/\/ host=localhost     \/\/ port=8080     let host_start = 20;     let host_end = 29;     let port_start = 36;     let port_end = 40;      let host = unsafe { std::str::from_utf8_unchecked(input.as_bytes().get(host_start..host_end).unwrap()) };      let mut port = 0u16;     let mut i = port_start;     while i &lt; port_end {         let digit = (input.as_bytes()[i] - b'0') as u16;         port = port * 10 + digit;         i += 1;     }      IniConfig { host, port } }  const INI_STR: &amp;str = \"[server]\\nhost=localhost\\nport=8080\"; const CONFIG_INI: IniConfig = parse_ini(INI_STR);  fn main() {     println!(\"\u041f\u0430\u0440\u0441\u0438\u043d\u0433 INI: {:?}\", CONFIG_INI); }<\/code><\/pre>\n<hr\/>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430! \u0415\u0441\u043b\u0438  \u0435\u0441\u0442\u044c \u0447\u0435\u043c \u0435\u0449\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u043f\u0438\u0448\u0438\u0442\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0441\u0432\u043e\u0438\u043c\u0438 \u043a\u0435\u0439\u0441\u0430\u043c\u0438 \u0441 const fn.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/892920\/\"> https:\/\/habr.com\/ru\/articles\/892920\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<hr\/>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p><code>const fn<\/code> \u0432 Rust \u0434\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0446\u0438\u043a\u043b\u044b, \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043c\u0430\u0442\u0447\u0438\u043d\u0433, \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0438 \u0434\u0430\u0436\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u2014 \u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h3>\u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u2014 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430. \u0422\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e n!, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0441\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0435\u0439. \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0441\u0430\u043c\u043e \u0447\u0438\u0441\u043b\u043e, \u0430 \u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>const fn<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b <strong>\u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> \u2014 \u0438 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u043d\u0438 \u0431\u0430\u0439\u0442\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 runtime.<\/p>\n<p>\u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"rust\">\/\/ \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u2014 \u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438! const fn factorial(n: u64) -&gt; u64 {     let mut result = 1;     let mut i = 1;     while i &lt;= n {         result *= i;         i += 1;     }     result }  \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 runtime const FACT_5: u64 = factorial(5);  fn main() {     println!(\"5! = {}\", FACT_5); \/\/ \u0412\u044b\u0432\u043e\u0434: 120 }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>factorial <\/code>\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>const fn<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442, \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 const-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 factorial(5) \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e 120 <strong>\u0443\u0436\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/strong>, \u0438 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0448\u0438\u0442 \u043b\u0438\u0442\u0435\u0440\u0430\u043b 120.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0435\u0437 const fn, \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0431\u044b \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0442\u0435\u0440\u0430\u043b (\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e),<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0432 <code>main()<\/code> (\u0438 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b),<\/p>\n<\/li>\n<li>\n<p>\u0438\u043b\u0438, \u0447\u0442\u043e \u0435\u0449\u0451 \u0445\u0443\u0436\u0435, \u0442\u0430\u0449\u0438\u0442\u044c \u044d\u0442\u043e \u0432 <code>lazy_static!<\/code> \u0438\u043b\u0438 <code>once_cell<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0430\u043a \u2014 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0447\u0438\u0441\u0442\u043e \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0433\u043e\u0442\u043e\u0432\u043e.<\/p>\n<h3>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0447\u0435\u043c\u0443-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u043c\u0443. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0435\u0434\u0440\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430 runtime \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0443, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0430\u0434\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<pre><code class=\"rust\">\/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430: a0 + a1*x + a2*x^2 + ... + an*x^n const fn eval_poly(coeffs: &amp;[i32], x: i32) -&gt; i32 {     let mut result = 0;     let mut pow = 1;     let mut i = 0;     while i &lt; coeffs.len() {         result += coeffs[i] * pow;         pow *= x;         i += 1;     }     result }  const COEFFS: &amp;[i32] = &amp;[3, 2, 5]; \/\/ \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u043e\u043b\u0438\u043d\u043e\u043c: 3 + 2*x + 5*x^2 const VALUE: i32 = eval_poly(COEFFS, 2); \/\/ \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435: 3 + 2*2 + 5*2^2 = 3 + 4 + 20 = 27  fn main() {     println!(\"\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430: {}\", VALUE); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>eval_poly<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>const fn<\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0440\u0435\u0437 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>x<\/code>, \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 <code>result = 0<\/code> \u0438 <code>pow = 1<\/code> (\u0433\u0434\u0435 pow \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c x), \u0437\u0430\u0442\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 <code>while <\/code>\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u043d\u0430 <code>pow<\/code>, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <code>pow<\/code>, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u0435\u0433\u043e \u043d\u0430 <code>x<\/code>, \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0443\u043c\u043c\u0443 \u0432\u0441\u0435\u0445 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>COEFFS <\/code>\u043a\u0430\u043a <code>[3, 2, 5]<\/code> (\u043f\u043e\u043b\u0438\u043d\u043e\u043c ) \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>const VALUE: i32 = eval_poly(COEFFS, 2)<\/code>, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 27. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f runtime \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u0442\u0440\u043e\u043a<\/h3>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 CSV, JSON \u0438\u043b\u0438 INI? \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. <\/p>\n<h4>CSV-\u043f\u0430\u0440\u0441\u0435\u0440<\/h4>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>Rust,Const,Cats<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0435\u0451 \u0432 runtime, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0435\u0451 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f const fn. <\/p>\n<pre><code class=\"rust\">\/\/ \u041f\u0440\u043e\u0441\u0442\u043e\u0439 CSV-\u043f\u0430\u0440\u0441\u0435\u0440, \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 3 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 const fn parse_csv(input: &amp;str) -&gt; [&amp;str; 3] {     let bytes = input.as_bytes();     let mut result: [&amp;str; 3] = [\"\"; 3];     let mut start = 0;     let mut idx = 0;     let mut i = 0;     while i &lt;= bytes.len() {         if i == bytes.len() || bytes[i] == b',' {             \/\/ Unsafe \u0442\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 CSV \u2013 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 UTF-8.             result[idx] = unsafe { std::str::from_utf8_unchecked(&amp;bytes[start..i]) };             idx += 1;             start = i + 1;         }         i += 1;     }     result }  const CSV_DATA: &amp;str = \"Rust,Const,Cats\"; const PARSED_CSV: [&amp;str; 3] = parse_csv(CSV_DATA);  fn main() {     for field in PARSED_CSV.iter() {         println!(\"\u041f\u043e\u043b\u0435: {}\", field);     } }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>input.as_bytes()<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0437\u0430\u043f\u044f\u0442\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a b&#8217;,&#8217;), \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432 result \u0438\u0437 \u0442\u0440\u0451\u0445 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438; \u0434\u0430\u043b\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0446\u0438\u043a\u043b while, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0431\u0430\u0439\u0442\u0430\u043c, \u0438 \u0435\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0430\u0432\u0435\u043d \u0434\u043b\u0438\u043d\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u044f\u0442\u0430\u044f, \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0441 start \u0434\u043e i \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u0435\u043c, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0435\u0433\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 <code>unsafe { std::str::from_utf8_unchecked(...) }<\/code> (\u0442.\u043a \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 UTF-8, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f const-\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430), \u0438 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f (<code>start = i + 1<\/code>) \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a <code>idx<\/code>.  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0432\u0441\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432\u044b\u0432\u043e\u0434 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. <\/p>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u0435\u0439\u0441\u0443 \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0433\u0434\u0435-\u0442\u043e \u0432 runtime, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e const fn \u0438 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct Config {     host: &amp;'static str,     port: u16,     use_ssl: bool, }  const fn create_config() -&gt; Config {     Config {         host: \"localhost\",         port: 8080,         use_ssl: false,     } }  const CONFIG: Config = create_config();  fn main() {     println!(\"\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f: {:?}\", CONFIG); }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Config<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (\u0430\u0434\u0440\u0435\u0441 \u0445\u043e\u0441\u0442\u0430, \u043f\u043e\u0440\u0442 \u0438 \u0444\u043b\u0430\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SSL), \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <code>#[derive(Debug)]<\/code> \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0451 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435; \u0437\u0430\u0442\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f<code> create_config<\/code>, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a <code>const fn<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 Config \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 <code>create_config()<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 main \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430.  <\/p>\n<h3>\u041c\u0438\u043d\u0438-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440<\/h3>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 Rust <strong>\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438<\/strong> \u0435\u0449\u0451 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<pre><code class=\"rust\">\/\/ \u041c\u0438\u043d\u0438-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0441 + \u0438 - \/\/ \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f: \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0444\u0440\u044b \u0438 \u0437\u043d\u0430\u043a\u0438 +\/-, \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432, \u0431\u0435\u0437 \u0441\u043a\u043e\u0431\u043e\u043a const fn eval_expr(expr: &amp;str) -&gt; i32 {     let bytes = expr.as_bytes();     let mut i = 0;     let mut current_number = 0;     let mut result = 0;     let mut current_sign = 1;     while i &lt; bytes.len() {         let c = bytes[i];         if c &gt;= b'0' &amp;&amp; c &lt;= b'9' {             current_number = current_number * 10 + (c - b'0') as i32;         } else {             result += current_sign * current_number;             current_number = 0;             current_sign = if c == b'+' { 1 } else { -1 };         }         i += 1;     }     result + current_sign * current_number }  const EXPR: &amp;str = \"12+34-5+6\"; const EVAL_RESULT: i32 = eval_expr(EXPR);  fn main() {     println!(\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f {}: {}\", EXPR, EVAL_RESULT); }<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as_bytes()<\/code>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u0440\u0443\u0447\u043d\u0443\u044e (\u0430 \u0432 <code>const fn<\/code> \u043d\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0438\u043f\u0430 <code>.split()<\/code> \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439). \u041f\u0440\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0430\u0439\u0442\u0430\u043c, \u0435\u0441\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0446\u0438\u0444\u0440\u0430 (\u043e\u0442 b&#8217;0&#8242; \u0434\u043e b&#8217;9&#8242;), \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>current_number<\/code>, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 10 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u0443\u044e \u0446\u0438\u0444\u0440\u0443.<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 (+ \u0438\u043b\u0438 -), \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f: \u043c\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 <code>result <\/code>\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c <code>current_number<\/code> \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u043a \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0430. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c, \u043e\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a <code>result <\/code>\u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u043a\u0430, \u0447\u0442\u043e \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0431\u0438\u043d\u0430\u0440\u044c, \u0430 \u0432 runtime \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0411\u0435\u0437 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0431\u0435\u0437 eval, \u0431\u0435\u0437 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439.<\/p>\n<h3>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438 \u0446\u0438\u043a\u043b\u044b \u0432 const \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435<\/h3>\n<p>\u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 const \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435. <\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct SimpleConfig {     host: &amp;'static str,     port: u16, }  \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e JSON \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. const fn parse_simple_json(json: &amp;str) -&gt; SimpleConfig {     \/\/ \u0416\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2013 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430     let host_start = 10;     let host_end = 19;     let port_start = 30;     let port_end = 34;      let host = unsafe { std::str::from_utf8_unchecked(json.as_bytes().get(host_start..host_end).unwrap()) };      let mut port = 0u16;     let mut i = port_start;     while i &lt; port_end {         let digit = (json.as_bytes()[i] - b'0') as u16;         port = port * 10 + digit;         i += 1;     }      SimpleConfig { host, port } }  const JSON_STR: &amp;str = r#\"{\"host\": \"localhost\", \"port\": 8080}\"#; const CONFIG_JSON: SimpleConfig = parse_simple_json(JSON_STR);  fn main() {     println!(\"\u041f\u0430\u0440\u0441\u0438\u043d\u0433 JSON: {:?}\", CONFIG_JSON); }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u043f\u0443\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<h3>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/h3>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, JSON-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"json\">{\"host\": \"localhost\", \"port\": 8080}<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043a\u0443\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u043e \u0438\u0434\u0435\u044f \u044f\u0441\u043d\u0430.<\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct SimpleConfig {     host: &amp;'static str,     port: u16, }  \/\/ \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e JSON \u0438\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. const fn parse_simple_json(json: &amp;str) -&gt; SimpleConfig {     \/\/ \u0416\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u2013 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430     let host_start = 10;     let host_end = 19;     let port_start = 30;     let port_end = 34;      let host = unsafe {<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-453967","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=453967"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453967\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}