{"id":365556,"date":"2024-05-21T02:40:47","date_gmt":"2024-05-21T02:40:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=365556"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:40:47","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=365556","title":{"rendered":"<span>\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0438\u043f\u043e\u0432 Rust<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/787008\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/mv\/0i\/ki\/mv0ikiutinpseo-fykipx548jec.png\" data-src=\"https:\/\/habrastorage.org\/webt\/mv\/0i\/ki\/mv0ikiutinpseo-fykipx548jec.png\"\/><\/div>\n<p><\/a><br \/>  \u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u2013 \u043d\u0430\u0443\u043a\u0430 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 Rust. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0435. <a name=\"habracut\"><\/a><\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430<\/font><\/h2>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0427\u0451\u0440\u0447\u0430. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0435\u0436\u0438\u0442 \u0438\u0434\u0435\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2013 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u044b \u043f\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0440\u0430\u0437\u0432\u0438\u043b\u0438 \u044d\u0442\u0443 \u0438\u0434\u0435\u044e \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u043f\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0447\u0438\u0441\u043b\u0430 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"plaintext\">0 = |f, x| x # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f 0 \u0440\u0430\u0437 1 = |f, x| f(x) # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f 1 \u0440\u0430\u0437 2 = |f, x| f(f(x)) # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f 2 \u0440\u0430\u0437\u0430 3 = |f, x| f(f(f(x))) # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f 3 \u0440\u0430\u0437\u0430 ... # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f ... \u0440\u0430\u0437 n = |f, x| f( .. n - 2 more f's .. f(x)) # f, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u0430\u044f n \u0440\u0430\u0437<\/code><\/pre>\n<p>  <i>n<\/i>-\u043d\u043e\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>n<\/i> \u0440\u0430\u0437. <\/p>\n<p>  \u0412 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0435 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0430\u043a\u0441\u0438\u043e\u043c\u044b \u041f\u0435\u0430\u043d\u043e. \u041e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u043f\u043e \u0441\u0443\u0442\u0438, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043e\u043f\u0443\u0449\u0435\u043d\u044b):<\/p>\n<pre><code class=\"plaintext\">0. 0 \u2013 \u044d\u0442\u043e \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. 1. \u0427\u0438\u0441\u043b\u043e, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c, S(n), \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u043c.<\/code><\/pre>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a:<\/p>\n<pre><code class=\"plaintext\">0 = 0 1 = S(0) 2 = S(1) = S(S(0)) 3.= S(2) = S(S(S(0))) ... n = S( .. n - 2 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 S .. S(0))<\/code><\/pre>\n<p>  \u0413\u0434\u0435 <code>S<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0431\u043e\u043b\u0435\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e. <\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430 \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0427\u0451\u0440\u0447\u0430?<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043a\u0430\u043a \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0435\u0435\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c Rust<\/font><\/h2>\n<p>  \u041a\u0430\u043a \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 Rust, \u0435\u0449\u0451 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e? \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043b\u044f\u043c\u0431\u0434\u044b, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435 (boxed clojure), \u043d\u043e \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2013 \u0432\u044b\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0432 \u0440\u043e\u043b\u0438 \u0431\u043e\u0433\u0430 \u0438 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u0430. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u044d\u0442\u043e \u043f\u0443\u0442\u044c Rust. \u041d\u043e \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u0438\u0434\u0435\u044e \u0438\u0437 \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u0441\u044e\u0434\u0430: <code>struct Wrapper&lt;T>(PhantomData&lt;T>)<\/code>. \u0418\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <code>T<\/code> \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0442\u0438\u043f\u0430 <code>T<\/code> \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u0442\u0438\u043f\u043e\u043c <code>Wrapper&lt;T><\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0438\u043f <code>Wrapper &lt;Wrapper&lt;Wrapper&lt;T>>><\/code>&#8230;<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435\u043c. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b:<\/p>\n<pre><code class=\"rust\">struct Zero; struct Succ&lt;T>(PhantomData&lt;T>);<\/code><\/pre>\n<p>  \u0414\u0430, \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0441\u043b\u043e\u0432\u043e <code>Succ<\/code> \u0437\u0432\u0443\u0447\u0438\u0442 \u0441\u043c\u0435\u0448\u043d\u043e (\u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0432\u0443\u0447\u0438\u0435 \u0441 \u0430\u043d\u0433\u043b. suck \u2013 \u0441\u043e\u0441\u0430\u0442\u044c, \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440.) \u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f <code>Successor<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430:<\/p>\n<pre><code class=\"rust\">type One = Succ&lt;Zero>; type Two = Succ&lt;Succ&lt;Zero>>; type Three = Succ&lt;Succ&lt;Succ&lt;Zero>>>; ...<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441:<\/p>\n<pre><code class=\"rust\">#[macro_export] macro_rules! encode { () => { Zero }; ($_a:tt $($tail:tt)*) => { Succ&lt;encode!($($tail)*)> }; }<\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0442\u043e\u043a\u0435\u043d\u044b, \u0438 \u043e\u043d \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u0438\u043c \u0442\u0438\u043f\u0443 \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 <code>Succ<\/code>. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"rust\"> encode!(* ***) ^ these tokens correspond to $tail = Succ&lt;encode!(* **)> = Succ&lt;Succ&lt;encode!(* *)>> = Succ&lt;Succ&lt;Succ&lt;encode!(*)>>> = Succ&lt;Succ&lt;Succ&lt;Succ&lt;encode!()>>>> ^ input is empty, so encode!() expands to Zero = Succ&lt;Succ&lt;Succ&lt;Succ&lt;Zero>>>><\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u043f\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>encode!(***** ... *****)<\/code>, \u0445\u043e\u0442\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0442\u0435\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u0440\u0438 3200 \u0442\u043e\u043a\u0435\u043d\u0430\u0445. <\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0434\u043b\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u0445 \u0438\u0437 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043d\u0430\u043c \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 (\u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e?), \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0412\u044b\u0445\u043e\u0434\u0438\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0442\u0438\u043f\u043e\u0432? \u0425\u043c\u043c\u2026 \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u0442\u0430\u043a\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0440\u0435\u0439\u0442\u044b.<\/p>\n<pre><code class=\"rust\">trait SpecialNumber { const MAGIC: usize; }  impl SpecialNumber for Foo { const MAGIC: usize = 13; }  impl SpecialNumber for Bar { const MAGIC: usize = 29; }<\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043b\u0438 \u0442\u0438\u043f <code>Foo<\/code> \u0432 <code>13<\/code>, \u0430 \u0442\u0438\u043f <code>Bar<\/code> \u2013 \u0432 <code>29<\/code>. \u0421\u043b\u0435\u0434\u0443\u044f \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0440\u0435\u0439\u0442 <code>Value<\/code>:<\/p>\n<pre><code class=\"rust\">trait Value { const VALUE: usize; }  impl Value for Zero { const VALUE: usize = 0; }  impl&lt;T> Value for Succ&lt;T> where T: Value { const VALUE: usize = 1 + T::VALUE; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u00ab\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u00bb \u0442\u0438\u043f \u2013 \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d <code>Succ<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u0435\u0439\u0441 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u043b\u043e\u044e <code>Succ<\/code>. <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435<\/font><\/h3>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e. \u041c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u0451\u043c\u0443, \u0445\u043e\u0442\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0435\u0436\u043d\u0435\u0439. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u043d\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b, \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0440\u0435\u0439\u0442 <code>Add<\/code> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"rust\">trait Add { type Sum; }<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u0435\u0439\u0441\u043e\u0432:<\/p>\n<pre><code class=\"rust\">impl Add for (Zero, Zero) { \/\/ 0 + 0 = 0 type Sum = Zero; }  impl&lt;T> Add for (Succ&lt;T>, Zero) { \/\/ x + 0 = x type Sum = Succ&lt;T>; }  impl&lt;T> Add for (Zero, Succ&lt;T>) { \/\/ 0 + x = x type Sum = Succ&lt;T>; }<\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"rust\">impl&lt;T, U> Add for (Succ&lt;T>, Succ&lt;U>) where (T, Succ&lt;Succ&lt;U>>): Add, { type Sum = &lt;(T, Succ&lt;Succ&lt;U>>) as Add>::Sum; }<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0431\u0435\u0440\u0451\u043c \u0434\u0432\u0430 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u2013 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0431\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0442\u0438\u043f\u043e\u0432 \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b \u0432 <code>Succ<\/code> \u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f <code>Succ&lt;..><\/code> \u0441\u0430\u043c\u0438. \u0418\u0434\u0435\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 <code>Succ<\/code> \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0442\u0438\u043f\u0430 \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0442\u044c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443. \u0422\u043e\u0433\u0434\u0430 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0451\u0442\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0441\u0451 <code>Succ<\/code> \u2013 \u043e\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e <code>Succ<\/code>, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d\u0438 \u043e\u0431\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438 \u2013 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0441\u0443\u043c\u043c\u0443 \u0434\u0432\u0443\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 (\u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u043b\u043e\u0451\u0432):<\/p>\n<pre><code class=\"rust\"> Add&lt;Succ&lt;Succ&lt;Zero>>, Succ&lt;Succ&lt;Zero>>> = Add&lt;Succ&lt;Zero>, Succ&lt;Succ&lt;Succ&lt;Zero>>>> \/\/ \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043e\u0434\u0438\u043d Succ \u0432\u043f\u0440\u0430\u0432\u043e = Add&lt;Zero, Succ&lt;Succ&lt;Succ&lt;Succ&lt;Zero>>>>> \/\/ \u043f\u043e\u0432\u0442\u043e\u0440 = Succ&lt;Succ&lt;Succ&lt;Succ&lt;Zero>>>>> \/\/ \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u0435\u0439\u0441 :)<\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0442\u0440\u0435\u0439\u0442\u0430 \u2013 \u043c\u044b \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c <i>rustc<\/i>, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0440\u0435\u0439\u0442 (\u0441\u0442\u0440\u0430\u043d\u043d\u0430\u044f \u0438\u0434\u0435\u044f, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438?), \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b.<\/p>\n<p>  \u0412\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0431\u0435\u0437\u0443\u043c\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438). \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u0435\u0439\u0441\u044b:<\/p>\n<pre><code class=\"rust\">trait Sub { type Diff; }  impl Sub for (Zero, Zero) { \/\/ 0 - 0 = 0 type Diff = Zero; }  impl&lt;T> Sub for (Succ&lt;T>, Zero) { \/\/ x - 0 = x type Diff = Succ&lt;T>; }  impl&lt;T> Sub for (Zero, Succ&lt;T>) { \/\/ 0 - x = 0, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u043c \u043d\u0430\u0441\u044b\u0449\u0435\u043d\u0438\u044f type Diff = Zero; }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043b\u0438\u0448\u044c \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0441\u044b\u0449\u0435\u043d\u0438\u0435. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438\u0437\u0431\u0430\u0432\u0438\u0442 \u0432\u0430\u0441 \u043e\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u041a\u0430\u043a \u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e, \u0432\u043e\u0442 \u043d\u0430\u0448\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<\/p>\n<pre><code class=\"rust\">impl&lt;T, U> Sub for (Succ&lt;T>, Succ&lt;U>) where (T, U): Sub, { type Diff = &lt;(T, U) as Sub>::Diff; }<\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 <code>Succ<\/code> \u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0442\u0438\u043f\u0430, \u043f\u043e\u043a\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u0435\u0432\u044b\u043c. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0439\u0441\u044f \u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c\u044e. \u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"plaintext\">5 [***] ** - 3 [***] = 2 [ ] **<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043e\u0431\u0449\u0438\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/font><\/h3>\n<p>  \u042d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0442\u0440\u0435\u0439\u0442\u0430 \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u0435\u0439\u0441\u043e\u0432:<\/p>\n<pre><code class=\"rust\">trait Mul { type Product; }  impl&lt;T> Mul for (T, Zero) { \/\/ x * 0 = 0 type Product = Zero; }  impl&lt;T> Mul for (Zero, Succ&lt;T>) { \/\/ 0 * x = 0 type Product = Zero; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0443\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u0435\u0435 \u0441 \u0442\u0435\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <code>Mul<\/code>. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f <code>(Zero, T)<\/code>, \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0431\u044b \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0435 <code>(Zero, Zero)<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0451 \u0434\u043b\u044f <code>(Zero, Succ&lt;T>)<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>Succ&lt;T><\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0432\u0435\u043d <code>Zero<\/code>. <\/p>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u043d\u0441\u0442\u0440:<\/p>\n<pre><code class=\"rust\">impl&lt;T, U> Mul for (Succ&lt;T>, Succ&lt;U>) where (T, Succ&lt;U>): Mul, (Succ&lt;U>, &lt;(T, Succ&lt;U>) as Mul>::Product): Add, { type Product = &lt;( Succ&lt;U>, \/\/ y &lt;(T, Succ&lt;U>) as Mul>::Product \/\/ (x - 1) * y ) as Add>::Sum; }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e <code>x * y = y + (x - 1) * y<\/code>. \u041c\u044b \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u043b\u0435\u043d, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u044e. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0435\u0441\u043b\u0438 <code>Succ&lt;T><\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>T + 1<\/code>, \u0442\u043e\u0433\u0434\u0430 <code>T<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <code>Succ&lt;T> - 1<\/code>.<\/p>\n<p>  \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446&#8230;<\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0414\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h3>\n<p>  \u0412\u043e\u0442 \u0442\u0443\u0442 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0443\u0436\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u043e\u043d\u0441\u0442\u0440. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>GreaterThanEq<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c <code>x >= y<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441 \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>7 \/ 3<\/code>. \u041e\u0431\u044a\u044f\u0441\u043d\u044e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435. \u041c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u043b\u0438 <code>Subtraction<\/code>:<\/p>\n<pre><code class=\"rust\">trait GreaterThanEq { type Greater; }  impl GreaterThanEq for (Zero, Zero) { \/\/ 0 >= 0 type Greater = Succ&lt;Zero>; }  impl&lt;T> GreaterThanEq for (Zero, Succ&lt;T>) { \/\/ 0 >!= { 1 .. } type Greater = Zero; }  impl&lt;T> GreaterThanEq for (Succ&lt;T>, Zero) { \/\/ { 1 .. } >= 0 type Greater = Succ&lt;Zero>; }  impl&lt;T, U> GreaterThanEq for (Succ&lt;T>, Succ&lt;U>) where (T, U): GreaterThanEq, \/\/ x >= y -> x - 1 >= y - 1 { type Greater = &lt;(T, U) as GreaterThanEq>::Greater; }<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u044d\u0442\u0438\u043c, \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <code>6 \/ 3<\/code>. \u0412\u043e\u0442 \u043d\u0430\u0448 \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442:<\/p>\n<pre><code class=\"rust\">trait Div { type Quotient; }  impl&lt;T> Div for (Zero, T) { \/\/ 0 \/ x = 0 type Quotient = Zero; }  impl&lt;T> Div for (Succ&lt;T>, Succ&lt;Zero>) { \/\/ x \/ 1 = x type Quotient = Succ&lt;T>; }<\/code><\/pre>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b\u043c\u0438 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f <code>(T, Succ&lt;Zero>)<\/code>, \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u043c \u0435\u0451 \u0434\u043b\u044f <code>(Succ&lt;T>, Succ&lt;Zero>)<\/code>, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u043b\u044f <code>(Zero, Succ&lt;Zero>)<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0436\u0434\u0435\u0441\u0442\u0432\u043e <code>x \/ y = 1 + (x - y) \/ y<\/code>. \u041f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043d\u0438\u043c\u0430\u0435\u043c \u0438\u0437 <code>x<\/code> \u043e\u0434\u043d\u0443 \u043a\u043e\u043f\u0438\u044e <code>y<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435. \u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"rust\">type RawQuotient&lt;T, U> = &lt;( Succ&lt;Zero>, \/\/ 1 &lt;( &lt;(Succ&lt;T>, Succ&lt;Succ&lt;U>>) as Sub>::Diff, Succ&lt;Succ&lt;U>>  ) as Div>::Quotient, \/\/ (x - y) \/ y ) as Add>::Sum;<\/code><\/pre>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u0438 <code>x &lt; y<\/code> \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 1. \u0412\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043d\u0430\u0441\u044b\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 0, \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>1 + 0 \/ y = 1 + 0 = 1<\/code>.<\/p>\n<p>  \u041d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 <code>RawQuotient<\/code> \u0441 \u0442\u0435\u043c \u0444\u0430\u043a\u0442\u043e\u043c, \u0447\u0442\u043e <code>x \/ y<\/code> \u0440\u0430\u0432\u043d\u043e 0, \u0435\u0441\u043b\u0438 <code>x &lt; y<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0451\u043c \u0441 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c (\u0438\u043b\u0438 <code>cmov<\/code> \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435). \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"plaintext\"> Case Boolean of Gte RawQuotient Desired +--------+ +----------------+ +-------------+ +---------+  | x >= y |: | 1 | x | nonzero | = | nonzero | +--------+ +----------------+ +-------------+ +---------+  | x &lt; y |: | 0 | x | ??? | = | 0 | +--------+ +----------------+ +-------------+ +---------+ <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c <code>RawQuotient<\/code>, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>x<\/code>. \u0415\u0441\u043b\u0438 <code>x >= y<\/code>, \u0443 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0430\u0448 <code>RawQuotient<\/code>. \u0415\u0441\u043b\u0438 \u0436\u0435 <code>x &lt; y<\/code>, \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0442\u044c \u043d\u0430 \u043d\u0443\u043b\u044c \u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0443\u043b\u044c, \u0447\u0442\u043e \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u0441\u0451 \u044d\u0442\u043e \u0432\u0435\u0434\u0451\u0442 \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">impl&lt;T, U> Div for (Succ&lt;T>, Succ&lt;Succ&lt;U>>) where (T, Succ&lt;U>): Sub, (&lt;(T, Succ&lt;U>) as Sub>::Diff, Succ&lt;Succ&lt;U>>): Div, ( Succ&lt;Zero>, &lt;(&lt;(T, Succ&lt;U>) as Sub>::Diff, Succ&lt;Succ&lt;U>>) as Div>::Quotient, ): Add, ( &lt;(Succ&lt;T>, Succ&lt;Succ&lt;U>>) as GreaterThanEq>::Greater, &lt;( Succ&lt;Zero>, &lt;(&lt;(T, Succ&lt;U>) as Sub>::Diff, Succ&lt;Succ&lt;U>>) as Div>::Quotient, ) as Add>::Sum, ): Mul, (Succ&lt;T>, Succ&lt;Succ&lt;U>>): GreaterThanEq, { \/\/ \u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c! type Quotient = &lt;( &lt;(Succ&lt;T>, Succ&lt;Succ&lt;U>>) as GreaterThanEq>::Greater, RawQuotient&lt;T, U>, ) as Mul>::Product; }<\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u043d\u0438\u0446 \u0442\u0440\u0435\u0439\u0442\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0446\u0435\u043f\u043e\u0447\u0435\u043a <code>Succ<\/code> \u0441 <code>Zero<\/code> \u0432\u043d\u0438\u0437\u0443. <\/p>\n<p>  \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u043b\u044f <code>(Succ &lt;T>, Succ&lt;Succ&lt;U>>)<\/code> \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043a\u0435\u0439\u0441 <code>Div<\/code>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u0431\u043e\u043b\u044c\u0448\u0435 1, \u0438 \u044d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0438 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<p>  \u0412 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435 Rust, \u044d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 0, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 <code>Div<\/code> \u0434\u043b\u044f <code>(*, Zero)<\/code>.<\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0432\u0441\u0451! \u041d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u043e\u0441\u0442\u043e\u0440\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u044b\u0442\u0430\u043b \u043f\u0440\u0438 \u0432\u0438\u0434\u0435 \u0437\u0435\u043b\u0451\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u0435\u0439\u0441\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u0438\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u0434 \u0438\u0437 \u00ab<a href=\"https:\/\/github.com\/fprasx\/arts\">Arithmetic in Rust&#8217;s Type System<\/a>\u00bb.<\/p>\n<h2><font color=\"#3AC1EF\">\u258d \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u043f\u0435\u0440\u0432\u044b\u0439, \u043a\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435, \u0445\u043e\u0442\u044f \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a. \u0421\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u0440\u0435\u0439\u0442\u043e\u0432 <a href=\"https:\/\/crates.io\/crates\/typenum\">typenum<\/a> \u0438 <a href=\"https:\/\/crates.io\/crates\/peano\">peano<\/a>. <code>typenum<\/code> \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0438 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d.<\/p>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0441\u0430\u043c\u0438\u043c. \u041e\u0447\u0435\u043d\u044c \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435. \u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0432\u0430\u043c \u0437\u0430 \u0437\u0432\u0435\u0437\u0434\u0443. <\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0434\u043d\u044f \ud83d\ude42<\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/t.me\/ruvds_community\">\u0421\u043a\u0438\u0434\u043a\u0438, \u0438\u0442\u043e\u0433\u0438 \u0440\u043e\u0437\u044b\u0433\u0440\u044b\u0448\u0435\u0439 \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u043e \u0441\u043f\u0443\u0442\u043d\u0438\u043a\u0435 RUVDS \u2014 \u0432 \u043d\u0430\u0448\u0435\u043c Telegram-\u043a\u0430\u043d\u0430\u043b\u0435 ?<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=%20arifmetika_pervogo_klassa_v_sisteme_tipov_rust\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4g\/dr\/oa\/4gdroaajo7o0zzvwwx5__rlzhwi.png\" data-src=\"https:\/\/habrastorage.org\/webt\/4g\/dr\/oa\/4gdroaajo7o0zzvwwx5__rlzhwi.png\"\/><\/a><\/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\/787008\/\"> https:\/\/habr.com\/ru\/articles\/787008\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/787008\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/mv\/0i\/ki\/mv0ikiutinpseo-fykipx548jec.png\" data-src=\"https:\/\/habrastorage.org\/webt\/mv\/0i\/ki\/mv0ikiutinpseo-fykipx548jec.png\"\/><\/div>\n<p><\/a><br \/>  \u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u2013 \u043d\u0430\u0443\u043a\u0430 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043a\u0441\u043f\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 Rust. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0435. <\/p>\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-365556","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365556","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=365556"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365556\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=365556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=365556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=365556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}