{"id":328147,"date":"2022-01-17T21:00:16","date_gmt":"2022-01-17T21:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328147"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328147","title":{"rendered":"<span>\u0421\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 Rust \u0432 \u0441\u0442\u0438\u043b\u0435 \u0421\/C++<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/www.mongodb.com\/developer\/how-to\/introduction-to-linked-lists-and-mongodb\/\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dc9\/bb1\/fda\/dc9bb1fda390e214ea4c475521eb7e96.png\"\/><\/a><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 Rust \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u0439 \u043e\u0442 \u0421\u0438 \u0438 C++? \u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/clehner\/ll.c\" rel=\"nofollow noopener noreferrer\">\u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0421\u0438<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">int *nums = NULL; int sum = 0; *(nums = ll_new(nums)) = 5; *(nums = ll_new(nums)) = 10;  ll_foreach(nums, num) {     sum += *num; } \/* sum == 15 *\/<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0421\u0414; \u041d\u041e<\/strong>: \u043d\u0435 \u043c\u043e\u0436\u0435\u0442. \u041f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0443\u0442\u044c, \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<ul>\n<li><strong>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/strong>: <a href=\"https:\/\/habr.com\/ru\/post\/588917\/\">\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f<\/a><\/li>\n<li><strong>\u041d\u0430\u0447\u0430\u043b\u043e \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/strong>: <a href=\"https:\/\/habr.com\/ru\/post\/566668\/\">\u0412\u043b\u0430\u0434\u0435\u043d\u0438\u0435<\/a><a name=\"habracut\"><\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"trudnosti-grafo-manii\">\u0422\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0433\u0440\u0430\u0444\u043e-\u043c\u0430\u043d\u0438\u0438<\/h1>\n<p>  <\/p>\n<p>\u0412\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0430, \u043a\u043e\u0433\u0434\u0430 \u044f \u0438\u0437\u0443\u0447\u0430\u043b \u0421\u0438 \u0438 \u0421++, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0433\u0440\u0430\u0444\u043e\u0432 \u0431\u044b\u043b\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0421\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0430\u044e\u0449\u0438\u0445 Rust \u044d\u0442\u0430 \u0442\u0435\u043c\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u2014 \u0433\u043e\u0440\u044f\u0447\u0430. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0438\u0442\u0430\u0442.<\/p>\n<p>  <\/p>\n<blockquote><p>If you want to create data structures which can be modified during runtime, a possible solution could lead into tree or graph like structures. Writing tree structures in Rust is no trivial problem. <\/p>\n<p>  <a href=\"https:\/\/rust-leipzig.github.io\/architecture\/2016\/12\/20\/idiomatic-trees-in-rust\/\" rel=\"nofollow noopener noreferrer\">Idiomatic tree and graph like structures in Rust<\/a>, <\/p><\/blockquote>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u043f\u0440\u0438\u0431\u044b\u0432\u0448\u0438\u0445 \u0432 Rust \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0440\u0435\u0431\u0435\u0440 \u0433\u0440\u0430\u0444\u043e\u0432 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0443\u0433\u0430\u044e\u0449\u0435:<br \/>  <img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/jx\/te\/gx\/jxtegxpvd8hzmzhzp3mezn_lxpk.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430 \u0432 &#171;\u0430\u0440\u0435\u043d\u0443&#187; \u0438 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0431\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0432\u0435\u0440\u0448\u0438\u043d. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  <\/p>\n<blockquote><p>\u0427\u0430\u0441\u0442\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u043e\u0431\u0443\u044e\u0449\u0438\u0445 \u0440\u0436\u0430\u0432\u0447\u0438\u043d\u0443 \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u2014 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442.\u043a. \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u043e\u0432 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0411\u044b\u0441\u0442\u0440\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0440\u0436\u0430\u0432\u0447\u0438\u043d\u0435 \u0432 \u043b\u043e\u0431 \u043d\u0435 \u0442\u0430\u043a-\u0442\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e <\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/oleg-bunin\/blog\/418449\/#comment_19072849\">\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/a> \u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/users\/ozkriff\/\" class=\"user_link\">ozkriff<\/a><\/p><\/blockquote>\n<p>ozkriff \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u0434\u0432\u0435 \u0441\u0441\u044b\u043b\u043a\u0438, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445, \u041a\u041c\u041a, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430:<\/p>\n<p>  <\/p>\n<blockquote><p>I fairly frequently get asked how to implement a linked list in Rust. The answer honestly depends on what your requirements are, and it&#8217;s obviously not super easy to answer the question on the spot. As such I&#8217;ve decided to write this book to comprehensively answer the question once and for all.<\/p>\n<p>  <a href=\"https:\/\/rust-unofficial.github.io\/too-many-lists\/index.html\" rel=\"nofollow noopener noreferrer\">Learn Rust With Entirely Too Many Linked Lists<\/a><\/p><\/blockquote>\n<p>\u0417\u0430\u043d\u044f\u0442\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f Rust \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u0442? \u041d\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446:<\/p>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u00ab\u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a\u00bb \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0430\u0445 \u0441 \u0413\u0426, \u0438 \u0438\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0435\u0451 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0441\u0442. \u042d\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/post\/433302\/#comment_19603958\">\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/a> \u043e\u0442 <a href=\"https:\/\/habr.com\/ru\/users\/psyhaste\/\" class=\"user_link\">PsyHaSTe<\/a><\/p><\/blockquote>\n<p>C\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 Rust \u0442\u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u043d\u0435 \u043b\u044e\u0431\u044f\u0442. \u0410 \u0437\u0430 \u0447\u0442\u043e \u0435\u0435 \u043b\u044e\u0431\u0438\u0442\u044c? \u0412\u0435\u0434\u044c \u0438 \u0441\u0430\u043c \u0411\u044c\u0451\u0440\u043d \u0421\u0442\u0440\u0430\u0443\u0441\u0442\u0440\u0443\u043f \u0437\u0430\u043d\u044f\u043b \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<blockquote><p>And, yes, my recomendation is to use std::vector by default. More generally, use a contiguous representation unless there is a good reason not to.<\/p>\n<p>  <a href=\"https:\/\/isocpp.org\/blog\/2014\/06\/stroustrup-lists\" rel=\"nofollow noopener noreferrer\">Are lists evil? \u2014 Bjarne Stroustrup<\/a><\/p><\/blockquote>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=w0I-MAaglM0&amp;t=40s\" rel=\"nofollow noopener noreferrer\">\u0422\u0435\u043c-\u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f?<\/a> \u0440\u0430\u0437\u0431\u043e\u0440 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 Rust \u0432 \u0441\u0442\u0438\u043b\u0435, \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u043c C\/C++.<\/p>\n<p>  <\/p>\n<h1 id=\"popytka-ne-pytka\">\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u0435 \u043f\u044b\u0442\u043a\u0430<\/h1>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 <a href=\"https:\/\/www.geeksforgeeks.org\/linked-list-set-1-introduction\/\" rel=\"nofollow noopener noreferrer\">\u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0440\u0430\u0436\u0430\u043d\u0438\u044f \u043d\u0430 C<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">struct Node {   int data;   struct Node *next; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u043d\u0430 Rust:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Node&lt;'a> {     data: i32,     next: &amp;'a Node&lt;'a>, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e, \u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u2014 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 (\u043e\u0442\u0441\u044e\u0434\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439), \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>null<\/code> \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0435\u0442 (\u0447\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0438\u043a\u0443\u0434\u0430).<\/p>\n<p>  <\/p>\n<p>&#171;\u0418\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439&#187; \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u043c\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0440\u044f\u0434\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u043b\u043e\u0432\u043e\u043a, \u0442\u0438\u043f\u0430 <code>Option<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u0443\u043c\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 <a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/eaf6f463599df1f18da94a6965e216ea15795417\/library\/alloc\/src\/boxed.rs#L190\" rel=\"nofollow noopener noreferrer\">Box<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct Box&lt; T: ?Sized, A: Allocator = Global,   ...     impl&lt;T> Box&lt;T> {   ...   pub fn new(x: T) -> Self {     box x   }   ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <code>box x<\/code>? <a href=\"https:\/\/play.rust-lang.org\/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=ee863dbcc55ba565b0c4ff693c8d641d\" rel=\"nofollow noopener noreferrer\">\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct MyBox&lt;T>(*mut T);  impl&lt;T> MyBox&lt;T> {     pub fn new(x: T) -> Self {         box x     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">> error[E0658]: box expression syntax is experimental; you can call `Box::new` instead > ... > 4 |     pub fn new(x: T) -> Self { >   |                         ---- expected `MyBox&lt;T>` because of return type > 5 |         box x >   |         ^^^^^ expected struct `MyBox`, found struct `Box`<\/code><\/pre>\n<p>  <\/p>\n<p>\u042f\u0441\u043d\u043e \u2014 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>box<\/code> \u0432\u0441\u0435 \u0435\u0449\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e <code>Box<\/code>. \u0423\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430\u0434\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439, \u043d\u043e \u043e\u0434\u0438\u043d \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u044b\u043d\u0435\u0441 \u0432 \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u043c\u044b <a href=\"https:\/\/habr.com\/ru\/post\/573422\/\">\u0438 \u0442\u0430\u043a \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c<\/a>, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u0443\u0447\u0435\u0439 \u2014 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0430\u0441\u043d\u043e, \u0437\u0430\u0442\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e. \u041f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<p>  <\/p>\n<h1 id=\"spisok-v-stile-si\">\u0421\u043f\u0438\u0441\u043e\u043a \u0432 \u0441\u0442\u0438\u043b\u0435 \u0421\u0438<\/h1>\n<p>  <\/p>\n<p>\u0423 \u0433\u0438\u043a\u043e\u0432 \u0421\u0438-\u0432\u0435\u0440\u0441\u0438\u044f &#171;Linked List Traversal&#187; \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 <a href=\"https:\/\/www.geeksforgeeks.org\/linked-list-set-1-introduction\/\" rel=\"nofollow noopener noreferrer\">\u0442\u0430\u043a<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">int main() {     struct Node* head = NULL;     struct Node* second = NULL;     struct Node* third = NULL;      \/\/ allocate 3 nodes in the heap     head = (struct Node*)malloc(sizeof(struct Node));     second = (struct Node*)malloc(sizeof(struct Node));     third = (struct Node*)malloc(sizeof(struct Node));      head->data = 1; \/\/ assign data in first node     head->next = second; \/\/ Link first node with second      second->data = 2; \/\/ assign data to second node     second->next = third;      third->data = 3; \/\/ assign data to third node     third->next = NULL;      printList(head);      return 0; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 Rust? <a href=\"https:\/\/play.rust-lang.org\/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=566b57078cd8a366f81ba87b31aa1d8c\" rel=\"nofollow noopener noreferrer\">\u0414\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">unsafe fn unsafe_main() {      let first: *mut Node = ptr::null_mut();     let second: *mut Node = ptr::null_mut();     let third: *mut Node = ptr::null_mut();      \/\/ allocate 3 nodes in the heap     let third = alloc(Layout::new::&lt;Node>()) as *mut Node;     let second = alloc(Layout::new::&lt;Node>()) as *mut Node;     let head = alloc(Layout::new::&lt;Node>()) as *mut Node;      (*head).data = 1; \/\/ assign data in first node     (*head).next = second; \/\/ Link first node with second      (*second).data = 2; \/\/ assign data to second node     (*second).next = third;      (*third).data = 3; \/\/ assign data to third node     (*third).next = ptr::null_mut();      print_list(head);     free_list(head); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0413\u0438\u043a\u0438, \u043f\u0440\u0430\u0432\u0434\u0430, \u0437\u0430\u0431\u044b\u043b\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0438\u0441\u0430\u0442\u044c <code>unsafe<\/code>. \u0412\u0441\u0435, \u0441 \u0421 <a href=\"https:\/\/www.youtube.com\/watch?v=i63jWjoAWHE&amp;t=168s\" rel=\"nofollow noopener noreferrer\">\u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c ?<\/a>.<\/p>\n<p>  <\/p>\n<h1 id=\"spisok-v-stile-c\">\u0421\u043f\u0438\u0441\u043e\u043a \u0432 \u0441\u0442\u0438\u043b\u0435 C++<\/h1>\n<p>  <\/p>\n<p>\u0412 Rust \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (\u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432), \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>drop()<\/code> (\u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043f\u0440\u043e \u0432\u044b\u0437\u043e\u0432 <code>free_list()<\/code>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d \u0436\u0438\u0437\u043d\u0438 (\u043d\u0435\u043b\u044c\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u043f\u0440\u043e\u0447.). <a href=\"https:\/\/play.rust-lang.org\/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=3301df0ec1442ac426054c4ea5c2fa93\" rel=\"nofollow noopener noreferrer\">\u0417\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0436\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e<\/a> \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 &#171;\u0441\u044b\u0440\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u0445&#187; (raw pointers):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub struct Item&lt;T> {     data: T,     next: *const Item&lt;T>, }  pub struct List&lt;T> {     head: *const Item&lt;T>, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0430 \u0432\u043e\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/588917\/\">\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub fn for_each&lt;F: FnMut(&amp;T)>(&amp;self, mut f: F) {     let mut cur = self.head;     while !cur.is_null() {         unsafe {             f(&amp;(*cur).data);             cur = (*cur).next;         }     } }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043b\u043e\u043a <code>unsafe<\/code>, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u044b\u0440\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/li>\n<\/ul>\n<p>  <\/p>\n<p><code>push()<\/code> \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0442\u0443\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    pub fn push(&amp;mut self, value: T) {         let pitem;         unsafe {             pitem = alloc(Layout::new::&lt;Item&lt;T>>()) as *mut Item&lt;T>;             std::ptr::write(&amp;mut (*pitem).data, value);             (*(pitem)).next = self.head;         }         self.head = pitem;     }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>alloc()<\/code> \u0438 <code>write()<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f unsafe, \u043a\u0430\u043a \u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435<\/li>\n<li>\u0412 <a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/20e92344bc46011de7d8deda2fb49c54ed2a6435\/library\/core\/src\/ptr\/mod.rs#L895\" rel=\"nofollow noopener noreferrer\">\u043d\u0435\u0434\u0440\u0430\u0445<\/a> <code>write()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 &#171;\u0437\u0430\u0431\u044b\u0432\u0430\u043d\u0438\u0435&#187; <code>value<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>drop()<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0447\u0443\u0434\u0435\u0441\u043d\u0430\u044f \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 main:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[cfg(test)] mod tests {     use super::*;     ...<\/code><\/pre>\n<p>  <\/p>\n<p><code>main()<\/code>, \u043e\u0434\u043d\u0430\u043a\u043e, \u0442\u043e\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u2014 \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">... \/\/ List of Points {     let mut ls = List::&lt;Point>::new();     ls.push(Point { x: 1, y: 2 });     ls.push(Point { x: 10, y: 20 });     ls.pop();             ls.push(Point { x: 100, y: 200 }); } ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">Dropping Point { x: 10, y: 20 }... Dropping List&lt;playground::Point>... Dropping Point { x: 100, y: 200 }... Dropping Point { x: 1, y: 2 }... ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0442\u043e\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u0432 \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a (\u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    \/\/ Attempt to put a short-lived reference to a long-lived list     {         let mut ls = List::&lt;&amp;String>::new();         let rstr: &amp;String;         let s = String::from(\"String 1\");         ls.push(&amp;s); \/\/  error[E0597]: `s` does not live long enough         rstr = ls.pop();         dbg!(rstr);     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0435\u0435 (\u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    \/\/ Attempt to pop a reference to a short-lived value to a long-lived value reference     {         let rstr: &amp;String;         {             let s = String::from(\"String 1\");             let mut ls = List::&lt;&amp;String>::new();             ls.push(&amp;s); \/\/ error[E0597]: `s` does not live long enough             rstr = ls.pop();         }         dbg!(rstr);     }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"rust\">   Compiling playground v0.0.1 (\/playground) error[E0597]: `s` does not live long enough    --> src\/main.rs:181:21     | 181 |             ls.push(&amp;s); \/\/ error[E0597]: `s` does not live long enough     |                     ^^ borrowed value does not live long enough 182 |             rstr = ls.pop(); 183 |         }     |         - `s` dropped here while still borrowed 184 |         dbg!(rstr);     |              ---- borrow later used here<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0433\u0443\u0447, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u043c\u043e\u0433\u0443\u0449 (\u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043f\u0430\u043d\u0438\u043a\u0443\u0435\u0442):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    \/\/ Pop from an empty list to a long-lived reference     {         let rstr: &amp;String;         {             let mut ls = List::&lt;&amp;String>::new();             rstr = ls.pop(); \/\/ thread 'main' panicked at 'assertion failed: !cur.is_null()', src\/main.rs:50:9         }         dbg!(rstr);     }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"nekotorye-razmyshleniya\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u0421\u043a\u043b\u043e\u043d\u0435\u043d \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e Rust \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 C \u0438 C++, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/leighmcculloch\/keywords\" rel=\"nofollow noopener noreferrer\">\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502                                                                                    ...... \u2502 \u2502                                                                                    ...... \u2502 \u2502                                                                             ...... ...... \u2502 \u2502                                                                             ...... ...... \u2502 \u2502                                                                      ...... ...... ...... \u2502 \u2502                                                                      ...... ...... ...... \u2502 \u2502                                                                      ...... ...... ...... \u2502 \u2502                                                                      ...... ...... ...... \u2502 \u2502                                                                      ...... ...... ...... \u2502 \u2502                                                        ...... ...... ...... ...... ...... \u2502 \u2502                                          ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502                                          ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502                            ...... ...... ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502              ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... \u2502 \u2502..22.. ..25.. ..26.. ..32.. ..35.. ..36.. ..49.. ..51.. ..52.. ..54.. ..89.. .100.. .109.. \u2502 \u2502Lua    Go     Erlang C      Python Ruby   JS     Java   Rust   Dart   Swift  C#     C++    \u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422.\u0435., \u0435\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c Rust \u043a\u0430\u043a &#171;\u0437\u0430\u043c\u0435\u043d\u0443&#187;, \u0442\u043e \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 &#171;\u0437\u0430\u043c\u0435\u043d\u0430&#187; \u044f\u0437\u044b\u043a\u0430 C, \u0447\u0435\u043c C++. \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Rust \u0432 \u044f\u0434\u0440\u0435 Linux \u0432\u043c\u0435\u0441\u0442\u043e \u0421 \u043c\u043d\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e (\u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b \u0438 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443).<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c, \u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e Rust \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043a Go \u2014 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0442\u0435\u0437\u0438\u0441 \u044f \u0432\u044b\u0434\u0432\u0438\u043d\u0443\u043b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f &#171;\u0433\u043e\u0444\u0435\u0440\u0430&#187; \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0446\u0435\u043d\u0435\u043d \u0442\u0430\u043a\u0438\u0439 \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0448\u0430\u0435\u0442 Rust? <\/p>\n<p>  <\/p>\n<ul>\n<li><strong>\u0412\u0438\u0441\u044f\u0447\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438<\/strong> (dangling reference). \u0412 Go \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e, \u0432\u0432\u0438\u0434\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u044c\u044e<\/li>\n<li><strong>GC overhead<\/strong>. \u0412 Go \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e, \u043d\u043e \u043d\u0435 \u0442\u0430\u043a \u0433\u043e\u0440\u044f\u0447\u0430, <a href=\"https:\/\/habr.com\/ru\/post\/487116\/\">\u043a\u0430\u043a \u0440\u0430\u043d\u0435\u0435<\/a>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 <a href=\"https:\/\/github.com\/VictoriaMetrics\/fastcache\" rel=\"nofollow noopener noreferrer\">\u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430<\/a> \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u044d\u0448\u0435\u0439<\/li>\n<li><strong>Data race<\/strong>. <a href=\"https:\/\/doc.rust-lang.org\/nomicon\/races.html\" rel=\"nofollow noopener noreferrer\">Safe Rust guarantees an absence of data races<\/a>, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e. \u0412 Go \u044d\u0442\u0430 \u0431\u043e\u043b\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u0438\u043b\u044c\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u043e\u043d\u0430 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0418 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438, \u0435\u0441\u0442\u044c \u043a\u043e\u0435-\u0447\u0442\u043e&#8230;<\/p>\n<p>  <\/p>\n<ul>\n<li>\u042d\u0422\u041e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 Go \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0441\u0442\u0440\u0430\u0434\u0430\u0442\u044c<\/li>\n<li>\u0412 Rust \u042d\u0422\u041e \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u043e \u042d\u0422\u041e <a href=\"https:\/\/www.youtube.com\/watch?v=_TML-ducRG8&amp;t=143s\" rel=\"nofollow noopener noreferrer\">\u0440\u0435\u0447\u044c \u0432\u043f\u0435\u0440\u0435\u0434\u0438?<\/a>.<\/p>\n<p>  <\/p>\n<h1 id=\"prilozhenie-pro-box-i-println\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u0440\u043e box \u0438 println!()<\/h1>\n<p>  <\/p>\n<p>\u0412 &#171;\u043d\u043e\u0447\u043d\u043e\u0439&#187; \u0432\u0435\u0440\u0441\u0438\u0438 box \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e <a href=\"https:\/\/play.rust-lang.org\/?version=nightly&amp;mode=debug&amp;edition=2021&amp;gist=2763296d112955757f1e3a30d4ccd195\" rel=\"nofollow noopener noreferrer\">\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#![feature(box_syntax)]  fn type_name&lt;T>(_: T) -> &amp;'static str {     std::any::type_name::&lt;T>() }  fn main() {     let five = box 5;     println!(\"{}\", five);     println!(\"{}\", type_name(five)); \/\/ alloc::boxed::Box&lt;i32> }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u0418\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043d\u0435 \u043d\u0430\u0448\u0435\u043b<\/li>\n<li>\u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0438\u0437 <code>box<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <code>Box<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0442\u0430\u043a\u043e\u0439 \u043d\u044e\u0430\u043d\u0441 \u2014 \u0435\u0441\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>println!<\/code> \u043d\u0430 <code>dbg!<\/code>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">8  |     let five = box 5;    |         ---- move occurs because `five` has type `Box&lt;i32>`, which does not implement the `Copy` trait 9  |     dbg!(\"{}\", five);    |     ---------------- value moved here 10 |     dbg!(\"{}\", type_name(five)); \/\/ alloc::boxed::Box&lt;i32>    |                          ^^^^ value used here after move<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 <code>dbg!()<\/code> \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2014 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0430\u044f &#171;\u043f\u044f\u0442\u0435\u0440\u043a\u0430&#187; \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, trait <code>Copy<\/code> \u0434\u043b\u044f <code>alloc::boxed::Box<\/code> \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>five<\/code> \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u043e. \u041d\u043e \u043a\u0430\u043a \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>println!()<\/code>?! \u0422\u0443\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0434\u0443\u043d\u0441\u0442\u0432\u043e (\u0434\u0435\u043b\u043e-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0447\u044c\u044e). <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c \u0434\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/2e2c86eba21a08cf505cd67073736d03ff3887ad\/library\/std\/src\/macros.rs#L94\" rel=\"nofollow noopener noreferrer\">println<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">macro_rules! println {     () => ($crate::print!(\"\\n\"));     ($($arg:tt)*) => ({         $crate::io::_print($crate::format_args_nl!($($arg)*));     }) }<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/83b15bfe1c15f325bc186ebfe3691b729ed59f2b\/library\/core\/src\/macros\/mod.rs#L872\" rel=\"nofollow noopener noreferrer\">format_args_nl<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    \/\/\/ Same as `format_args`, but adds a newline in the end.     macro_rules! format_args_nl {         ($fmt:expr) => {{ \/* compiler built-in *\/ }};         ($fmt:expr, $($args:tt)*) => {{ \/* compiler built-in *\/ }};     }<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/83b15bfe1c15f325bc186ebfe3691b729ed59f2b\/library\/core\/src\/macros\/mod.rs#L842\" rel=\"nofollow noopener noreferrer\">format_args<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">    macro_rules! format_args {         ($fmt:expr) => {{ \/* compiler built-in *\/ }};         ($fmt:expr, $($args:tt)*) => {{ \/* compiler built-in *\/ }};     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u0440\u0438\u043a\u043e\u043b\u044c\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u044d\u0442\u043e\u0442 Rust \u2014 \u0432 \u043d\u0435\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0435\u0437 \u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0430\u043c\u0430\u043d\u0441\u0442\u0432\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0443\u0447\u0443 \u0438 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0434\u0435\u043b\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/646105\/\"> https:\/\/habr.com\/ru\/post\/646105\/<\/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_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/www.mongodb.com\/developer\/how-to\/introduction-to-linked-lists-and-mongodb\/\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dc9\/bb1\/fda\/dc9bb1fda390e214ea4c475521eb7e96.png\"\/><\/a><\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 Rust \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u0439 \u043e\u0442 \u0421\u0438 \u0438 C++? \u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/github.com\/clehner\/ll.c\" rel=\"nofollow noopener noreferrer\">\u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u0421\u0438<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">int *nums = NULL; int sum = 0; *(nums = ll_new(nums)) = 5; *(nums = ll_new(nums)) = 10;  ll_foreach(nums, num) {     sum += *num; } \/* sum == 15 *\/<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0421\u0414; \u041d\u041e<\/strong>: \u043d\u0435 \u043c\u043e\u0436\u0435\u0442. \u041f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0443\u0442\u044c, \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<ul>\n<li><strong>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/strong>: <a href=\"https:\/\/habr.com\/ru\/post\/588917\/\">\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f<\/a><\/li>\n<li><strong>\u041d\u0430\u0447\u0430\u043b\u043e \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/strong>: <a href=\"https:\/\/habr.com\/ru\/post\/566668\/\">\u0412\u043b\u0430\u0434\u0435\u043d\u0438\u0435<\/a><br \/>\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-328147","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328147","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=328147"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328147\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}