{"id":368689,"date":"2024-05-21T03:47:37","date_gmt":"2024-05-21T03:47:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368689"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368689","title":{"rendered":"<span>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e Rust. 2\/4<\/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\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/fj\/yi\/qn\/fjyiqnduv3l-rdgxnbu_t_qpgxk.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/fj\/yi\/qn\/fjyiqnduv3l-rdgxnbu_t_qpgxk.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>Hello world!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e <a href=\"https:\/\/www.rust-lang.org\/ru\/\">Rust<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/790556\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/796567\/\">\u0422\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/801201\/\">\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/802609\/\">\u0411\u043e\u043d\u0443\u0441<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/my-js.org\/docs\/guide\/rust\/\">\u0414\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 <a href=\"https:\/\/google.github.io\/comprehensive-rust\/index.html\">Comprehensive Rust<\/a> \u2014 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043f\u043e <code>Rust<\/code> \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>Android<\/code> \u0432 <code>Google<\/code> \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0432\u043b\u0430\u0434\u0435\u044e\u0442 \u043b\u044e\u0431\u044b\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0415\u0449\u0435 \u0440\u0430\u0437: \u044d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u043e\u0434\u0438\u0442\u044c ?<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043c\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c (pattern matching) \u2014 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440<\/li>\n<li>\u043c\u0435\u0442\u043e\u0434\u044b \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438<\/li>\n<li>\u0442\u0440\u0435\u0439\u0442\u044b (traits) \u2014 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043e\u0431\u0449\u0435\u0435 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432<\/li>\n<li>\u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 (generics) \u2014 \u043e\u0431\u0449\u0438\u0435 \u0442\u0438\u043f\u044b<\/li>\n<li>\u0442\u0438\u043f\u044b \u0438 \u0442\u0440\u0435\u0439\u0442\u044b, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <code>Rust<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0435\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/doc.rust-lang.ru\/book\">\u041a\u043d\u0438\u0433\u0430\/\u0443\u0447\u0435\u0431\u043d\u0438\u043a \u043f\u043e Rust<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435) \u2014 \u0433\u043b\u0430\u0432\u044b 6, 8, 10, 13, 17 \u0438 18<\/li>\n<li><a href=\"https:\/\/github.com\/rust-lang\/rustlings\">rustlings<\/a> \u2014 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f 04-06, 09, 11, 12, 14 \u0438 15<\/li>\n<li><a href=\"https:\/\/doc.rust-lang.ru\/stable\/rust-by-example\/\">Rust \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435) \u2014 5, 6, 14, 16, 19 \u0438 20<\/li>\n<li><a href=\"https:\/\/practice.rs\/why-exercise.html\">Rust by practice<\/a> \u2014 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f 8-12 \u0438 18<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043c. <a href=\"https:\/\/my-js.org\/docs\/cheatsheet\/rust\/\">\u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0443 \u043f\u043e Rust<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"sopostavlenie-s-obrazcom\">\u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c<\/h2>\n<p>  <\/p>\n<p><strong>\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 (tuples), \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b (structs) \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (enums) \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f (destructure) \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c:<\/p>\n<p>  <\/p>\n<p><em>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Foo {     x: (u32, u32),     y: u32, }  \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 #[rustfmt::skip] fn main() {     let foo = Foo { x: (1, 2), y: 3 };     match foo {         Foo { x: (1, b), y } => println!(\"x.0 = 1, b = {b}, y = {y}\"),         Foo { y: 2, x: i }   => println!(\"y = 2, x = {i:?}\"),         Foo { y, .. }        => println!(\"y = {y}, \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f\"),     } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/em><\/p>\n<p>  <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d\u044b (patterns) \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043a \u0447\u0430\u0441\u0442\u044f\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u042d\u0442\u043e, \u043f\u043e\u043c\u0438\u043c\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <code>enum<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">enum Result {     Ok(i32),     Err(String), }  fn divide_in_two(n: i32) -> Result {     if n % 2 == 0 {         Result::Ok(n \/ 2)     } else {         Result::Err(format!(\"\u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c {n} \u043d\u0430 2 \u0440\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438\"))     } }  fn main() {     let n = 100;     match divide_in_two(n) {         Result::Ok(half) => println!(\"{n}, \u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 2: {half}\"),         Result::Err(msg) => println!(\"\u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430: {msg}\"),     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <code>Result<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 2 \u0431\u043b\u043e\u043a\u0430 (\u0440\u0443\u043a\u0438\/\u0440\u0443\u043a\u0430\u0432\u0430 \u2014 arms). \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0431\u043b\u043e\u043a\u0435 <code>half<\/code> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 <code>Ok<\/code>. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0431\u043b\u043e\u043a\u0435 <code>msg<\/code> \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 (\u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 <code>Err<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <code>foo<\/code> \u0434\u043b\u044f \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438<\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0432 <code>Foo<\/code> \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0439\u0442\u0435 \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <code>if-else<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>match<\/code><\/li>\n<li>\u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0438 \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435<\/li>\n<li>\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c<\/li>\n<li>\u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0438\u043c<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041f\u043e\u0442\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>let<\/code><\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>if let<\/code><\/li>\n<li><code>while let<\/code><\/li>\n<li><code>match<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>if let<\/em><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/doc.rust-lang.org\/reference\/expressions\/if-expr.html#if-let-expressions\">if-let<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn sleep_for(secs: f32) {     let dur = if let Ok(dur) = std::time::Duration::try_from_secs_f32(secs) {         dur     } else {         std::time::Duration::from_millis(500)     };     std::thread::sleep(dur);     println!(\"\u0441\u043f\u0430\u043b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 {:?}\", dur); }  fn main() {     \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u0431\u043b\u043e\u043a\u0430 `else`     sleep_for(-10.0);     \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u0431\u043b\u043e\u043a\u0430 `if`     sleep_for(0.8); }<\/code><\/pre>\n<p>  <\/p>\n<p><em>let-else<\/em><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/doc.rust-lang.org\/rust-by-example\/flow_control\/let_else.html\">let-else<\/a>. \u041a\u043e\u0434 \u0431\u043b\u043e\u043a\u0430 <code>else<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (<code>return<\/code>, <code>break<\/code>, <code>panic!<\/code> \u0438 \u0442.\u043f.).<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn hex_or_die_trying(maybe_string: Option&lt;String>) -> Result&lt;u32, String> {     let s = if let Some(s) = maybe_string {         s     } else {         return Err(String::from(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e `None`\"));     };      let first_byte_char = if let Some(first_byte_char) = s.chars().next() {         first_byte_char     } else {         return Err(String::from(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\"));     };      if let Some(digit) = first_byte_char.to_digit(16) {         Ok(digit)     } else {         Err(String::from(\"\u043d\u0435 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\"))     } }  fn main() {     println!(\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: {:?}\", hex_or_die_trying(Some(String::from(\"foo\")))); \/\/ 15 - \u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 `f` }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <a href=\"https:\/\/doc.rust-lang.org\/reference\/expressions\/loop-expr.html#predicate-pattern-loops\">while-let<\/a> \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let mut name = String::from(\"Comprehensive Rust ?\");     while let Some(c) = name.pop() {         println!(\"\u0441\u0438\u043c\u0432\u043e\u043b: {c}\");     }     \/\/ \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b ? }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/string\/struct.String.html#method.pop\">String::pop()<\/a> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Some(c)<\/code> \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>None<\/code>. <code>while-let<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>if-let:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>match<\/code>, <code>if-let<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u043c, \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>match<\/code><\/li>\n<li>\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>if-let<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 <code>Some<\/code> \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>Option<\/code><\/li>\n<li>\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>match<\/code>, <code>if-let<\/code> \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u043d\u0438\u043a\u043e\u0432 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (match guards)<\/li>\n<\/ul>\n<p>  <\/p>\n<p>let-else:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>let-else<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0443 (flattening) \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">fn hex_or_die_trying(maybe_string: Option&lt;String>) -> Result&lt;u32, String> {     let Some(s) = maybe_string else {         return Err(String::from(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e `None`\"));     };      let Some(first_byte_char) = s.chars().next() else {         return Err(String::from(\"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\"));     };      let Some(digit) = first_byte_char.to_digit(16) else {         return Err(String::from(\"\u043d\u0435 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\"));     };      return Ok(digit); }<\/code><\/pre>\n<p>  <\/p>\n<p>while-let:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0446\u0438\u043a\u043b <code>while-let<\/code> \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c<\/li>\n<li>\u0446\u0438\u043a\u043b <code>while-let<\/code> \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <code>if<\/code> \u0432\u043d\u0443\u0442\u0440\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442 \u0446\u0438\u043a\u043b, \u043a\u043e\u0433\u0434\u0430 <code>name.pop()<\/code> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435: \u043e\u0446\u0435\u043d\u043a\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f <code>Box<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (smart pointer), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0437\u0436\u0435. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e &#171;\u0443\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Box::new()<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445. \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f (<code>*<\/code>): <code>eval(*boxed_expr)<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0438\u043f <code>Result&lt;Value, String><\/code> \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (<code>Ok(Value)<\/code>) \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 (<code>Err(String)<\/code>). \u041c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u043d\u0430\u0434 \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 #[derive(Debug)] enum Operation {     Add,     Sub,     Mul,     Div, }  \/\/ \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u043e\u0440\u043c\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 #[derive(Debug)] enum Expression {     \/\/ \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0434 \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438     Op {         op: Operation,         left: Box&lt;Expression>,         right: Box&lt;Expression>,     },      \/\/ \u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435     Value(i64), }  \/\/ \u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 fn eval(e: Expression) -> Result&lt;i64, String> {     todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\") }  fn main() {     let expr = Expression::Op {         op: Operation::Sub,         left: Box::new(Expression::Value(20)),         right: Box::new(Expression::Value(10)),     };     println!(\"\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435: {:?}\", expr);     println!(\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: {:?}\", eval(expr)); }  \/\/ \u041c\u043e\u0434\u0443\u043b\u044c \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 - \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b `cargo test` #[cfg(test)] mod tests {     use super::*;      #[test]     fn test_value() {         assert_eq!(eval(Expression::Value(19)), Ok(19));     }      #[test]     fn test_sum() {         assert_eq!(             eval(Expression::Op {                 op: Operation::Add,                 left: Box::new(Expression::Value(10)),                 right: Box::new(Expression::Value(20)),             }),             Ok(30)         );     }      #[test]     fn test_recursion() {         let term1 = Expression::Op {             op: Operation::Mul,             left: Box::new(Expression::Value(10)),             right: Box::new(Expression::Value(9)),         };         let term2 = Expression::Op {             op: Operation::Mul,             left: Box::new(Expression::Op {                 op: Operation::Sub,                 left: Box::new(Expression::Value(3)),                 right: Box::new(Expression::Value(4)),             }),             right: Box::new(Expression::Value(5)),         };         assert_eq!(             eval(Expression::Op {                 op: Operation::Add,                 left: Box::new(term1),                 right: Box::new(term2),             }),             Ok(85)         );     }      #[test]     fn test_error() {         assert_eq!(             eval(Expression::Op {                 op: Operation::Div,                 left: Box::new(Expression::Value(99)),                 right: Box::new(Expression::Value(0)),             }),             Err(String::from(\"\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u043b\u044c\"))         );     } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">fn eval(e: Expression) -> Result&lt;i64, String> {     \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442     match e {         \/\/ \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f.         \/\/ \u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044f         Expression::Op { op, left, right } => {             \/\/ \u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043b\u0435\u0432\u043e\u0435 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435             let left = match eval(*left) {                 Ok(v) => v,                 Err(e) => return e,             };             \/\/ \u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u0435 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435             let right = match eval(*right) {                 Ok(v) => v,                 Err(e) => return e,             };             \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 `Ok`             Ok(               \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438               match op {                   Operation::Add => left + right,                   Operation::Sub => left - right,                   Operation::Mul => left * right,                   Operation::Div => {                       \/\/ \u0415\u0441\u043b\u0438 \u043f\u0440\u0430\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f 0                       if right == 0 {                           \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0443 (caller) \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435, \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u043e\u0435 \u0432 `Err`.                           \/\/ \u041c\u044b \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c (propagate) \u043e\u0448\u0438\u0431\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u043d\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 `Ok`                           return Err(String::from(\"\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u043e\u043b\u044c\"));                       } else {                           left \/ right                       }                   }               }             )         }         \/\/ \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435.         \/\/ \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0443\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 `Ok`         Expression::Value(v) => Ok(v),     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"metody-i-treyty\">\u041c\u0435\u0442\u043e\u0434\u044b \u0438 \u0442\u0440\u0435\u0439\u0442\u044b<\/h2>\n<p>  <\/p>\n<p><strong>\u041c\u0435\u0442\u043e\u0434\u044b<\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a \u0442\u0438\u043f\u0430\u043c (\u0442\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u2014 \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445). \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u043b\u043e\u043a\u0430 <code>impl<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct Race {     name: String,     laps: Vec&lt;i32>, }  impl Race {     \/\/ \u041d\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434     fn new(name: &amp;str) -> Self {         Self { name: String::from(name), laps: Vec::new() }     }      \/\/ \u042d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0435 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 (exclusive borrowing), \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0435\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 `self`     fn add_lap(&amp;mut self, lap: i32) {         self.laps.push(lap);     }      \/\/ \u041e\u0431\u0449\u0435\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 (shared borrowing) `self`     fn print_laps(&amp;self) {         println!(\"\u0417\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u0440\u0435\u043c\u044f {} \u043a\u0440\u0443\u0433\u043e\u0432 \u0434\u043b\u044f {}:\", self.laps.len(), self.name);         for (idx, lap) in self.laps.iter().enumerate() {             println!(\"\u041a\u0440\u0443\u0433 {idx}: {lap} \u0441\u0435\u043a\u0443\u043d\u0434\");         }     }      \/\/ \u042d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u043d\u043e\u0435 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 (exclusive ownership) `self`     fn finish(self) {         let total: i32 = self.laps.iter().sum();         println!(\"\u0413\u043e\u043d\u043a\u0430 {} \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f: {}\", self.name, total);     } }  fn main() {     let mut race = Race::new(\"Monaco Grand Prix\");     race.add_lap(70);     race.add_lap(68);     race.print_laps();     race.add_lap(71);     race.print_laps();     race.finish();     \/\/ race.add_lap(42); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>self<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 &#171;\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f&#187; (receiver) \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434. \u041f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>&amp;self<\/code> \u2014 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0449\u0435\u0439 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d<\/li>\n<li><code>&amp;mut self<\/code> \u2014 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d<\/li>\n<li><code>self<\/code> \u2014 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u043e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e. \u041c\u0435\u0442\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041e\u0431\u044a\u0435\u043a\u0442 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f (\u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f) \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0443\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u043e\u043b\u043d\u043e\u0435 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/li>\n<li><code>mut self<\/code> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <code>self<\/code>, \u043d\u043e \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442<\/li>\n<li>\u043d\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f \u2014 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c. \u041e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>new()<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<br \/> \n<ul>\n<li>\u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0442\u0438\u043f\u0430 (\u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435), \u0438\u0445 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u0441\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 (<code>self<\/code>)<\/li>\n<li>\u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0443\u0447\u0448\u0435\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430<\/li>\n<\/ul>\n<\/li>\n<li>\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>self<\/code>:<br \/> \n<ul>\n<li><code>self<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f <code>self: Self<\/code>, \u0432\u043c\u0435\u0441\u0442\u043e <code>Self<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Race<\/code><\/li>\n<li>\u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>Self<\/code> \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u043e\u043d\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e\u0433\u043e (<code>impl<\/code>) \u0442\u0438\u043f\u0430 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430<\/li>\n<li><code>self<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u0435\u0447\u043d\u0430\u044f \u043d\u043e\u0442\u0430\u0446\u0438\u044f<\/li>\n<li>\u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 <code>&amp;self<\/code> \u0438 <code>self<\/code> \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <code>finish()<\/code> \u0434\u0432\u0430\u0436\u0434\u044b<\/li>\n<li>\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 <a href=\"https:\/\/doc.rust-lang.org\/reference\/special-types-and-traits.html\">\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0442\u0438\u043f\u043e\u0432<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Box&lt;Self><\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0422\u0440\u0435\u0439\u0442\u044b<\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0439\u0442\u043e\u0432 (traits). \u041e\u043d\u0438 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Dog {     name: String,     age: i8, } struct Cat {     lives: i8, }  trait Pet {     fn talk(&amp;self) -> String;      fn greet(&amp;self) {         println!(\"\u041a\u0430\u043a\u0430\u044f \u043c\u0438\u043b\u0430\u0445\u0430! \u041a\u0430\u043a \u0442\u0435\u0431\u044f \u0437\u043e\u0432\u0443\u0442? {}\", self.talk());     } }  impl Pet for Dog {     fn talk(&amp;self) -> String {         format!(\"\u0413\u0430\u0432, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 {}!\", self.name)     } }  impl Pet for Cat {     fn talk(&amp;self) -> String {         String::from(\"\u041c\u0430\u0443!\")     } }  fn main() {     let captain_floof = Cat { lives: 9 };     let fido = Dog { name: String::from(\"\u0424\u0438\u0434\u043e\"), age: 5 };      captain_floof.greet();     fido.greet(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0442\u0440\u0435\u0439\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430<\/li>\n<li>\u0442\u0440\u0435\u0439\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 <code>impl &lt;trait> for &lt;type> { .. }<\/code><\/li>\n<li>\u0442\u0440\u0435\u0439\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u0430\u043a \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0442\u0430\u043a \u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435: <code>greet()<\/code> \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 <code>talk()<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0439\u0442\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435\/\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug, Clone, Default)] struct Player {     name: String,     strength: u8,     hit_points: u8, }  fn main() {     let p1 = Player::default(); \/\/ \u0442\u0440\u0435\u0439\u0442 `Default` \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 `default()`.     let mut p2 = p1.clone(); \/\/ \u0442\u0440\u0435\u0439\u0442 `Clone` \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 `clone()`     p2.name = String::from(\"EldurScrollz\");     \/\/ \u0422\u0440\u0435\u0439\u0442 `Debug` \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e `{:?}`.     println!(\"{:?} vs. {:?}\", p1, p2); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u0440\u0435\u0439\u0442\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/crates.io\/crates\/serde\">serde<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>#[derive(Serialize)]<\/code>.<\/p>\n<p>  <\/p>\n<p><strong>\u0422\u0440\u0435\u0439\u0442-\u043e\u0431\u044a\u0435\u043a\u0442\u044b<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0439\u0442-\u043e\u0431\u044a\u0435\u043a\u0442\u044b (trait objects) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Dog {     name: String,     age: i8, } struct Cat {     lives: i8, }  trait Pet {     fn talk(&amp;self) -> String; }  impl Pet for Dog {     fn talk(&amp;self) -> String {         format!(\"\u0413\u0430\u0432, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 {}!\", self.name)     } }  impl Pet for Cat {     fn talk(&amp;self) -> String {         String::from(\"\u041c\u0430\u0443!\")     } }  fn main() {     \/\/ \u0422\u0440\u0435\u0439\u0442-\u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0440\u0435\u0439\u0442 `Pet`     let pets: Vec&lt;Box&lt;dyn Pet>> = vec![         Box::new(Cat { lives: 9 }),         Box::new(Dog { name: String::from(\"\u0424\u0438\u0434\u043e\"), age: 5 }),     ];     for pet in pets {         println!(\"\u041f\u0440\u0438\u0432\u0435\u0442, \u043a\u0442\u043e \u0442\u044b? {}\", pet.talk());     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f <code>pets<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/cf\/ri\/s6\/cfris6v-ltwp4tskiepa4rghw9e.png\" data-src=\"https:\/\/habrastorage.org\/webt\/cf\/ri\/s6\/cfris6v-ltwp4tskiepa4rghw9e.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0442\u0438\u043f\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442, \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438, \u043a\u0430\u043a <code>Vec&lt;dyn Pet><\/code> \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435<\/li>\n<li><code>dyn Pet<\/code> \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043e \u0442\u0438\u043f\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>Pet<\/code><\/li>\n<li>\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>pets<\/code> \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u0442\u0435\u043a\u0435 (stack), \u0430 \u0432\u0435\u043a\u0442\u043e\u0440 \u2014 \u0432 \u043a\u0443\u0447\u0435 (heap). 2 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0436\u0438\u0440\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 (fat pointers):<br \/> \n<ul>\n<li>\u0436\u0438\u0440\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u2014 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u044b. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Virtual_method_table\">\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/a> (vtable) \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Pet<\/code> \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/li>\n<li>\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f <code>Dog<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>name<\/code> \u0438 <code>age<\/code>. <code>Cat<\/code> \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u0435 <code>lives<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u044d\u0442\u0438 \u0432\u044b\u0432\u043e\u0434\u044b:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">println!(\"{} {}\", std::mem::size_of::&lt;Dog>(), std::mem::size_of::&lt;Cat>()); println!(\"{} {}\", std::mem::size_of::&lt;&amp;Dog>(), std::mem::size_of::&lt;&amp;Cat>()); println!(\"{}\", std::mem::size_of::&lt;&amp;dyn Pet>()); println!(\"{}\", std::mem::size_of::&lt;Box&lt;dyn Pet>>());<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 GUI<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 GUI (graphical user interface \u2014 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441). \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0433\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u0432\u044b\u0432\u043e\u0434 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Window<\/code> \u2014 \u0438\u043c\u0435\u0435\u0442 <code>title<\/code> \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b<\/li>\n<li><code>Button<\/code> \u2014 \u0438\u043c\u0435\u0435\u0442 <code>label<\/code>. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0435\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f<\/li>\n<li><code>Label<\/code> \u2014 \u0438\u043c\u0435\u0435\u0442 <code>label<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0438\u0434\u0436\u0435\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0442\u0440\u0435\u0439\u0442 <code>Widget<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>draw_into()<\/code> \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0439\u0442\u0430 <code>Widget<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait Widget {     \/\/ \u041d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0448\u0438\u0440\u0438\u043d\u0430 `self`.     fn width(&amp;self) -> usize;      \/\/ \u0420\u0438\u0441\u0443\u0435\u043c\/\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0438\u0434\u0436\u0435\u0442 \u0432 \u0431\u0443\u0444\u0435\u0440     fn draw_into(&amp;self, buffer: &amp;mut dyn std::fmt::Write);      \/\/ \u0420\u0438\u0441\u0443\u0435\u043c \u0432\u0438\u0434\u0436\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434     fn draw(&amp;self) {         let mut buffer = String::new();         self.draw_into(&amp;mut buffer);         println!(\"{buffer}\");     } }  \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a pub struct Label {     label: String, }  impl Label {     \/\/ \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u043e\u0434\u043f\u0438\u0441\u0438     fn new(label: &amp;str) -> Label {         Label { label: label.to_owned() }     } }  pub struct Button {     label: Label, }  impl Button {     \/\/ \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043d\u043e\u043f\u043a\u0438     fn new(label: &amp;str) -> Button {         Button { label: Label::new(label) }     } }  pub struct Window {     title: String,     widgets: Vec&lt;Box&lt;dyn Widget>>, }  impl Window {     \/\/ \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u043a\u043d\u0430     fn new(title: &amp;str) -> Window {         Window { title: title.to_owned(), widgets: Vec::new() }     }      \/\/ \u041c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430     fn add_widget(&amp;mut self, widget: Box&lt;dyn Widget>) {         self.widgets.push(widget);     }      \/\/ \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u044b     fn inner_width(&amp;self) -> usize {         std::cmp::max(             self.title.chars().count(),             self.widgets.iter().map(|w| w.width()).max().unwrap_or(0),         )     } }  impl Widget for Window {     todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\") } impl Widget for Button {     todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\") } impl Widget for Label {     todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\") }  fn main() {     let mut window = Window::new(\"Rust GUI Demo 1.23\");     window.add_widget(Box::new(Label::new(\"This is a small text GUI demo.\")));     window.add_widget(Box::new(Button::new(\"Click me!\")));     window.draw(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">======== Rust GUI Demo 1.23 ========  This is a small text GUI demo.  | Click me! |<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043b\u0438 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/doc.rust-lang.org\/std\/fmt\/index.html#fillalignment\">\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\/\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f<\/a> \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430. \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>\/<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let width = 10;     println!(\"\u0441\u043b\u0435\u0432\u0430:     |{:\/&lt;width$}|\", \"foo\");     println!(\"\u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443: |{:\/^width$}|\", \"foo\");     println!(\"\u0441\u043f\u0440\u0430\u0432\u0430:    |{:\/>width$}|\", \"foo\"); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u043f\u0440\u0438\u0435\u043c\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">+--------------------------------+ |       Rust GUI Demo 1.23       | +================================+ | This is a small text GUI demo. | | +-------------+                | | |  Click me!  |                | | +-------------+                | +--------------------------------+<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">impl Widget for Window {     fn width(&amp;self) -> usize {         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0448\u0438\u0440\u0438\u043d\u0435 4 \u0434\u043b\u044f \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446         \/\/ (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0441\u0442\u0443\u043f\u0443 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b)         self.inner_width() + 4     }      fn draw_into(&amp;self, buffer: &amp;mut dyn std::fmt::Write) {         let mut inner = String::new();         for widget in &amp;self.widgets {             widget.draw_into(&amp;mut inner);         }          let inner_width = self.inner_width();          \/\/ TODO: \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a,         \/\/ \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043e\u0434 `draw_into()` \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b `Result&lt;(), std::fmt::Error>`         \/\/ \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 ? \u0432\u043c\u0435\u0441\u0442\u043e `unwrap()`         writeln!(buffer, \"+-{:-&lt;inner_width$}-+\", \"\").unwrap();         writeln!(buffer, \"| {:^inner_width$} |\", &amp;self.title).unwrap();         writeln!(buffer, \"+={:=&lt;inner_width$}=+\", \"\").unwrap();         for line in inner.lines() {             writeln!(buffer, \"| {:inner_width$} |\", line).unwrap();         }         writeln!(buffer, \"+-{:-&lt;inner_width$}-+\", \"\").unwrap();     } }  impl Widget for Button {     fn width(&amp;self) -> usize {         self.label.width() + 4 \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 (\u043f\u043e 2 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b)     }      fn draw_into(&amp;self, buffer: &amp;mut dyn std::fmt::Write) {         let width = self.width();         let mut label = String::new();         self.label.draw_into(&amp;mut label);          writeln!(buffer, \"+{:-&lt;width$}+\", \"\").unwrap();         for line in label.lines() {             writeln!(buffer, \"|{:^width$}|\", &amp;line).unwrap();         }         writeln!(buffer, \"+{:-&lt;width$}+\", \"\").unwrap();     } }  impl Widget for Label {     fn width(&amp;self) -> usize {         self.label.lines().map(|line| line.chars().count()).max().unwrap_or(0)     }      fn draw_into(&amp;self, buffer: &amp;mut dyn std::fmt::Write) {         writeln!(buffer, \"{}\", &amp;self.label).unwrap();     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"dzheneriki\">\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/h2>\n<p>  <\/p>\n<p><strong>\u041e\u0431\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 (generics), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0438\u043b\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e) \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0438\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u0442\u0438\u043f\u0430\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 `even` \u0438\u043b\u0438 `odd` \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f `n`. \/\/ \u0417\u0434\u0435\u0441\u044c `T` - \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 (type parameter), \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430 fn pick&lt;T>(n: i32, even: T, odd: T) -> T {     if n % 2 == 0 {         even     } else {         odd     } }  fn main() {     println!(\"\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e: {:?}\", pick(97, 222, 333));     println!(\"\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0440\u0442\u0435\u0436: {:?}\", pick(28, (\"dog\", 1), (\"cat\", 2))); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Rust<\/code> \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f\u044b \u0434\u043b\u044f <code>T<\/code> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0438\u043f\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0438\u043f\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/li>\n<li>\u044d\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u044b (templates) <code>C++<\/code>, \u043d\u043e <code>Rust<\/code> \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0440\u0430\u0437\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0442\u0438\u043f\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>pick()<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 <code>even + odd<\/code>, \u0435\u0441\u043b\u0438 <code>n == 0<\/code>. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>pick()<\/code> \u0441 \u0446\u0435\u043b\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, <code>Rust<\/code> \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0435 \u043d\u0435\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439. <code>C++<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/li>\n<li>\u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 (\u043d\u0435\u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439) \u043a\u043e\u0434 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\u044e: \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0435\u0437 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041e\u0431\u0449\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug)] struct Point&lt;T> {     x: T,     y: T, }  impl&lt;T> Point&lt;T> {     fn coords(&amp;self) -> (&amp;T, &amp;T) {         (&amp;self.x, &amp;self.y)     }      \/\/ fn set_x(&amp;mut self, x: T) }  fn main() {     let integer = Point { x: 5, y: 10 };     let float = Point { x: 1.0, y: 4.0 };     println!(\"{integer:?} \u0438 {float:?}\");     println!(\"\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b: {:?}\", integer.coords()); }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0447\u0435\u043c\u0443 <code>T<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u0432\u0430\u0436\u0434\u044b \u0432 <code>impl&lt;T> Point&lt;T><\/code>? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e:<br \/> \n<ul>\n<li>\u044d\u0442\u043e \u043e\u0431\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430 \u2014 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438<\/li>\n<li>\u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e <code>T<\/code><\/li>\n<li>\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>impl Point&lt;u32><\/code>, \u0442\u043e\u0433\u0434\u0430:<\/li>\n<li><code>Point<\/code> \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u043c, \u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Point&lt;f64><\/code>, \u043d\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u044d\u0442\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f <code>Point&lt;u32><\/code><\/li>\n<\/ul>\n<\/li>\n<li>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043d\u043e\u0432\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>let p = Point { x: 5, y: 10.0 };<\/code> \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 2 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>T<\/code> \u0438 <code>U<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0439\u0442\u043e\u043c<\/strong><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438 \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0442\u0438\u043f\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0440\u0435\u0439\u0442, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>T: Trait<\/code> \u0438\u043b\u0438 <code>impl Trait<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn duplicate&lt;T: Clone>(a: T) -> (T, T) {     (a.clone(), a.clone()) }  \/\/ struct NotClonable;  fn main() {     let foo = String::from(\"foo\");     let pair = duplicate(foo);     println!(\"{pair:?}\"); }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>NotClonable<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0435 \u0432 <code>duplicate()<\/code><\/li>\n<li>\u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>+<\/code> \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u0442\u0440\u0435\u0442\u044c\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0439\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>where<\/code>:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">fn duplicate&lt;T>(a: T) -> (T, T) where     T: Clone, {     (a.clone(), a.clone()) }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>where<\/code> &#171;\u043e\u0447\u0438\u0449\u0430\u0435\u0442&#187; \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0435 \u043c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/li>\n<li><code>where<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u043c:<br \/> \n<ul>\n<li>\u0442\u0438\u043f \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 <code>:<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c (<code>Option&lt;T><\/code>)<\/li>\n<li>\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>Rust<\/code> (\u043f\u043e\u043a\u0430) \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e (\u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e <code>duplicate()<\/code>, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e <code>duplicate(a: u32)<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>impl Trait<\/strong><\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 \u0442\u0440\u0435\u0439\u0442\u043e\u043c, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>impl Trait<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u0434\u043b\u044f: \/\/   fn add_42_millions&lt;T: Into&lt;i32>>(x: T) -> i32 { fn add_42_millions(x: impl Into&lt;i32>) -> i32 {     x.into() + 42_000_000 }  fn pair_of(x: u32) -> impl std::fmt::Debug {     (x + 1, x - 1) }  fn main() {     let many = add_42_millions(42_i8);     println!(\"{many}\");     let many_more = add_42_millions(10_000_000);     println!(\"{many_more}\");     let debuggable = pair_of(27);     println!(\"\u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439: {debuggable:?}\"); }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>impl Trait<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>impl Trait<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u0435\u0441\u0442\u0430 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<br \/> \n<ul>\n<li>\u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>impl Trait<\/code> \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u043e\u0431\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u0440\u0435\u0439\u0442\u043e\u043c<\/li>\n<li>\u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u2014 \u044d\u0442\u043e \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u0437\u043d\u0430\u043a, \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0432 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c API<\/li>\n<\/ul>\n<\/li>\n<li>\u043a\u0430\u043a\u043e\u0432 \u0442\u0438\u043f <code>debuggable<\/code>? \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 <code>let debuggable: () = ..<\/code> \u0438 \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0438 \u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0439\u0442\u0430 <code>LessThan<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0431\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>min()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">trait LessThan {     \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c `true`, \u0435\u0441\u043b\u0438 `self` \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c `other`     fn less_than(&amp;self, other: &amp;Self) -> bool; }  #[derive(Debug, PartialEq, Eq, Clone, Copy)] struct Citation {     author: &amp;'static str,     year: u32, }  impl LessThan for Citation {     fn less_than(&amp;self, other: &amp;Self) -> bool {         if self.author &lt; other.author {             true         } else if self.author > other.author {             false         } else {             self.year &lt; other.year         }     } }  fn min() {     todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\") }  fn main() {     let cit1 = Citation { author: \"Shapiro\", year: 2011 };     let cit2 = Citation { author: \"Baumann\", year: 2010 };     let cit3 = Citation { author: \"Baumann\", year: 2019 };     \/\/ \u041e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f `assert_eq!`, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a     debug_assert_eq!(min(cit1, cit2), cit2);     debug_assert_eq!(min(cit2, cit3), cit2);     debug_assert_eq!(min(cit1, cit3), cit3); }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">fn min&lt;T: LessThan>(l: T, r: T) -> T {     if l.less_than(&amp;r) {         l     } else {         r     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"tipy-predostavlyaemye-standartnoy-bibliotekoy-rust\">\u0422\u0438\u043f\u044b, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Rust<\/h2>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0449\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438 <code>Rust<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0441\u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0431\u0435 \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0438\u043f <code>String<\/code>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 <code>Rust<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <code>core<\/code>, <code>alloc<\/code> \u0438 <code>std<\/code>:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>core<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0430\u043c\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 <code>libc<\/code>, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f (allocator) \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/li>\n<li><code>alloc<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0442\u0438\u043f\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u043a\u0443\u0447\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>Vec<\/code>, <code>Box<\/code> \u0438 <code>Arc<\/code><\/li>\n<li>\u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 <code>Rust<\/code>, \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <code>core<\/code> \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 <code>alloc<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 <a href=\"https:\/\/doc.rust-lang.org\/stable\/reference\/expressions\/loop-expr.html\">\u0446\u0438\u043a\u043b\u043e\u0432<\/a><\/li>\n<li>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/primitive.u8.html\">u8<\/a><\/li>\n<li>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/option\/enum.Option.html\">Option<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/collections\/struct.BinaryHeap.html\">BinaryHeap<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \/\/\/ \/\/\/ \u0415\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f 0, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f `false` fn is_divisible_by(lhs: u32, rhs: u32) -> bool {     if rhs == 0 {         return false;     }     lhs % rhs == 0 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>Markdown<\/code>. \u0412\u0441\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u043a\u0440\u0435\u0439\u0442\u044b (crates) <code>Rust<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0430 <a href=\"https:\/\/docs.rs\/\">docs.rs<\/a> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <a href=\"https:\/\/doc.rust-lang.org\/rustdoc\/what-is-rustdoc.html\">rusdoc<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>\/\/!<\/code> \u0438\u043b\u0438 <code>\/*! .. *\/<\/code>, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 &#171;\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430&#187;:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/! \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a\u0440\u0435\u0439\u0442\u0430 <a href=\"https:\/\/docs.rs\/rand\">rand<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>Option<\/strong><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0441 <code>Option<\/code>. \u041e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u043b\u0438\u0431\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Some(T)<\/code>, \u043b\u0438\u0431\u043e \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>None<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/string\/struct.String.html#method.find\">String::find()<\/a> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Option&lt;usize><\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let name = \"L\u00f6we \u8001\u864e L\u00e9opard Gepardi\";     let mut position: Option&lt;usize> = name.find('\u00e9');     println!(\"find \u0432\u0435\u0440\u043d\u0443\u043b {position:?}\");     assert_eq!(position.unwrap(), 14);     position = name.find('Z');     println!(\"find \u0432\u0435\u0440\u043d\u0443\u043b {position:?}\");     assert_eq!(position.expect(\"\u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"), 0); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Option<\/code> \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435<\/li>\n<li><code>unwrap()<\/code> \u043b\u0438\u0431\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Some<\/code>, \u043b\u0438\u0431\u043e \u043f\u0430\u043d\u0438\u043a\u0443\u0435\u0442. <code>expect()<\/code> \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>unwrap()<\/code>, \u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435<br \/> \n<ul>\n<li>\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0430\u043d\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043d\u0430 <code>None<\/code>, \u043d\u043e \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c &#171;\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e&#187; \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c <code>None<\/code><\/li>\n<li><code>unwrap()<\/code>\/<code>expect()<\/code> \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 <code>Some<\/code> \u0432 \u043c\u0435\u0441\u0442\u0430\u0445, \u0433\u0434\u0435 \u043c\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u043e\u0434\u0430. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 <code>None<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c<\/li>\n<\/ul>\n<\/li>\n<li>\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0438\u0448\u0438 (niche optimization) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>Option&lt;T><\/code> \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u043a\u043e\u043b\u044c\u043a\u043e <code>T<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>Result<\/strong><\/p>\n<p>  <\/p>\n<p><code>Result<\/code> \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>Option<\/code>, \u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0430\u043b\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0442\u0438\u043f\u043e\u043c. \u0412 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0435 <code>Result&lt;T, E><\/code> <code>T<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 <code>Ok<\/code>, \u0430 <code>E<\/code> \u2014 \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 <code>Err<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::fs::File; use std::io::Read;  fn main() {     let file: Result&lt;File, std::io::Error> = File::open(\"diary.txt\");     match file {         Ok(mut file) => {             let mut contents = String::new();             if let Ok(bytes) = file.read_to_string(&amp;mut contents) {                 println!(\"{contents}\\n({bytes} \u0431\u0430\u0439\u0442)\");             } else {                 println!(\"\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b\");             }         }         Err(err) => {             println!(\"\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043d\u0435\u0432\u043d\u0438\u043a: {err}\");         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>Option<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>Result<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>unwrap()<\/code>\/<code>expect()<\/code><\/li>\n<li><code>Result<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/li>\n<li><code>Result<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u043e \u0447\u0435\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430<\/li>\n<li>\u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c\/\u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0442\u0438\u043f <code>Result&lt;T, std::io::Error><\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e <code>std::io<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <code>Result<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>Ok<\/code>:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::fs::File; use std::io::{Read, Result};  \/\/ `main()` \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c `Result` fn main() -> Result&lt;()> {     \/\/ \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 `?` \u043b\u0438\u0431\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 `Ok`, \u043b\u0438\u0431\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 (\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0443)     let mut file = File::open(\"diary.txt\")?;     let mut contents = String::new();     let bytes = file.read_to_string(&amp;mut contents)?;     println!(\"{contents}\\n({bytes} \u0431\u0430\u0439\u0442)\");     Ok(()) }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>String<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/doc.rust-lang.org\/std\/string\/struct.String.html\">String<\/a> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0432 \u043a\u0443\u0447\u0435 (heap-allocated) \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 (growable) UTF-8 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u0431\u0443\u0444\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let mut s1 = String::new();     s1.push_str(\"\u043f\u0440\u0438\u0432\u0435\u0442\");     println!(\"s1: \u0434\u043b\u0438\u043d\u0430 = {}, \u0435\u043c\u043a\u043e\u0441\u0442\u044c = {}\", s1.len(), s1.capacity());      let mut s2 = String::with_capacity(s1.len() + 1);     s2.push_str(&amp;s1);     s2.push('!');     println!(\"s2: \u0434\u043b\u0438\u043d\u0430 = {}, \u0435\u043c\u043a\u043e\u0441\u0442\u044c = {}\", s2.len(), s2.capacity());      let s3 = String::from(\"??\");     println!(\"s3: \u0434\u043b\u0438\u043d\u0430 = {}, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 = {}\", s3.len(), s3.chars().count()); }<\/code><\/pre>\n<p>  <\/p>\n<p><code>String<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <a href=\"https:\/\/doc.rust-lang.org\/std\/string\/struct.String.html#deref-methods-str\">Deref&lt;Target = str><\/a>: \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>str<\/code> \u043d\u0430 <code>String<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>String::new()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>String::with_capacity()<\/code><\/li>\n<li><code>String::len()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 <code>String<\/code> \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432)<\/li>\n<li><code>String::chars()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>char<\/code> \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0442\u044c &#171;\u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c&#187;, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e <a href=\"https:\/\/docs.rs\/unicode-segmentation\/latest\/unicode_segmentation\/struct.Graphemes.html\">\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430\u043c \u0433\u0440\u0430\u0444\u0435\u043c<\/a> (grapheme clusters)<\/li>\n<li>\u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0441\u0442\u0440\u043e\u043a\u0430\u0445, \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e <code>&amp;str<\/code> \u0438\u043b\u0438 <code>String<\/code><\/li>\n<li>\u043a\u043e\u0433\u0434\u0430 \u0442\u0438\u043f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>Deref&lt;Target = T><\/code>, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <code>T<\/code><br \/> \n<ul>\n<li><code>String<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>Deref&lt;Target = str><\/code>, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0435\u0442\u043e\u0434\u0430\u043c <code>str<\/code><\/li>\n<li>\u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 <code>let s3 = s1.deref();<\/code> \u0438 <code>let s3 = &amp;*s1;<\/code><\/li>\n<\/ul>\n<\/li>\n<li><code>String<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0431\u0430\u0439\u0442, \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f <code>String<\/code>, \u043d\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u044f\u043c\u0438)<\/li>\n<li>\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>String<\/code>:<br \/> \n<ul>\n<li>\u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>s3.chars().nth(i).unwrap()<\/code>, \u0433\u0434\u0435 <code>i<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0437\u0430 \u0438\u0445 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438<\/li>\n<li>\u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 (\u0441\u0440\u0435\u0437\u0430 \u2014 slice) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>s3[0..4]<\/code>, \u0433\u0434\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (character boundaries) \u0438 \u0437\u0430 \u0438\u0445 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>Vec<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/doc.rust-lang.org\/std\/vec\/struct.Vec.html\">Vec<\/a> \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 (resizable) \u0431\u0443\u0444\u0435\u0440, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0432 \u043a\u0443\u0447\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let mut v1 = Vec::new();     v1.push(42);     println!(\"v1: \u0434\u043b\u0438\u043d\u0430 = {}, \u0435\u043c\u043a\u043e\u0441\u0442\u044c = {}\", v1.len(), v1.capacity());      let mut v2 = Vec::with_capacity(v1.len() + 1);     v2.extend(v1.iter());     v2.push(9999);     println!(\"v2: \u0434\u043b\u0438\u043d\u0430 = {}, \u0435\u043c\u043a\u043e\u0441\u0442\u044c = {}\", v2.len(), v2.capacity());      \/\/ \u041a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438     let mut v3 = vec![0, 0, 1, 2, 3, 4];      \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0442\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b     v3.retain(|x| x % 2 == 0);     println!(\"{v3:?}\");      \/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b     v3.dedup();     println!(\"{v3:?}\"); }<\/code><\/pre>\n<p>  <\/p>\n<p><code>Vec<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <a href=\"https:\/\/doc.rust-lang.org\/std\/vec\/struct.Vec.html#deref-methods-%5BT%5D\">Deref&lt;Target = [T]><\/a>: \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0440\u0435\u0437\u043e\u0432 \u043d\u0430 <code>Vec<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Vec<\/code> \u2014 \u044d\u0442\u043e \u0442\u0438\u043f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043d\u0430\u0440\u044f\u0434\u0443 \u0441 <code>String<\/code> \u0438 <code>HashMap<\/code>. \u0414\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e <code>Vec&lt;T><\/code> \u2014 \u044d\u0442\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a, \u043d\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <code>T<\/code>. <code>Rust<\/code> \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>push()<\/code><\/li>\n<li><code>vec![..]<\/code> \u2014 \u044d\u0442\u043e \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 <code>Vec::new()<\/code>, \u043d\u043e \u0441 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/li>\n<li>\u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>[]<\/code>, \u043d\u043e \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u043f\u0430\u043d\u0438\u043a\u0443\u0435\u0442. \u0411\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>get()<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <code>Option<\/code>. \u041c\u0435\u0442\u043e\u0434 <code>pop()<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430<\/li>\n<li><code>Vec<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0440\u0435\u0437\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>HashMap<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0445\u0435\u0448-\u043a\u0430\u0440\u0442\u0430 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 HashDoS-\u0430\u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::collections::HashMap;  fn main() {     let mut page_counts = HashMap::new();     page_counts.insert(\"Adventures of Huckleberry Finn\".to_string(), 207);     page_counts.insert(\"Grimms' Fairy Tales\".to_string(), 751);     page_counts.insert(\"Pride and Prejudice\".to_string(), 303);      if !page_counts.contains_key(\"Les Mis\u00e9rables\") {         println!(             \"We know about {} books, but not Les Mis\u00e9rables.\",             page_counts.len()         );     }      for book in [\"Pride and Prejudice\", \"Alice's Adventure in Wonderland\"] {         match page_counts.get(book) {             Some(count) => println!(\"{book}: {count} pages\"),             None => println!(\"{book} is unknown.\"),         }     }      \/\/ \u041c\u0435\u0442\u043e\u0434 `entry()` \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u044e\u0447\u0435\u0439     for book in [\"Pride and Prejudice\", \"Alice's Adventure in Wonderland\"] {         let page_count: &amp;mut i32 = page_counts.entry(book.to_string()).or_insert(0);         *page_count += 1;     }      println!(\"{page_counts:#?}\"); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>HashMap<\/code> \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0438 (prelude) \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044f\u0432\u043d\u043e<\/li>\n<li>\u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043b\u0438 \u043a\u043d\u0438\u0433\u0430 \u0432 \u043a\u0430\u0440\u0442\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0435\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438. \u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043a\u043d\u0438\u0433\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0432 \u043a\u0430\u0440\u0442\u0435:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">let pc1 = page_counts     .get(\"Harry Potter and the Sorcerer's Stone\")     .unwrap_or(&amp;336); let pc2 = page_counts     .entry(\"The Hunger Games\".to_string())     .or_insert(374);<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>vec!<\/code>, <code>Rust<\/code>, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0440\u043e\u0441 <code>hashmap!<\/code><br \/> \n<ul>\n<li>\u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <code>Rust 1.56<\/code>, <code>HashMap<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <a href=\"https:\/\/doc.rust-lang.org\/std\/collections\/hash_map\/struct.HashMap.html#impl-From%3C%5B(K,+V);+N%5D%3E-for-HashMap%3CK,+V,+RandomState%3E\">From&lt;[(K, V); N]><\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u044d\u0448-\u043a\u0430\u0440\u0442\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">let page_counts = HashMap::from([   (\"Harry Potter and the Sorcerer's Stone\".to_string(), 336),   (\"The Hunger Games\".to_string(), 374), ]);<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>HashMap<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e <code>Iterator<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u0438 <code>(\u043a\u043b\u044e\u0447, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435)<\/code><\/li>\n<li>\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043c\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>&amp;str<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0445\u044d\u0448-\u043a\u0430\u0440\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0441 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435\u043c<\/li>\n<li>\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 <code>HashMap<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435: \u0441\u0447\u0435\u0442\u0447\u0438\u043a<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0438 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>HashMap<\/code> \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f <code>Counter<\/code> \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 <code>u32<\/code>. \u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b <code>Counter<\/code> \u043c\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0430\u043c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043b\u0435\u0433\u043a\u0438\u043c \u0438 \u0432\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u0441 \u043d\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>entry()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u0434\u0432\u043e\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0445\u0435\u0448\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::collections::HashMap;  \/\/ `Counter` \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u043e\u0441\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 `T` struct Counter {     values: HashMap&lt;u32, u64>, }  impl Counter {     \/\/ \u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e `Counter`     fn new() -> Self {         Counter {             values: HashMap::new(),         }     }      \/\/ \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     fn count(&amp;mut self, value: u32) {         if self.values.contains_key(&amp;value) {             *self.values.get_mut(&amp;value).unwrap() += 1;         } else {             self.values.insert(value, 1);         }     }      \/\/ \u041c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     fn times_seen(&amp;self, value: u32) -> u64 {         self.values.get(&amp;value).copied().unwrap_or_default()     } }  fn main() {     let mut ctr = Counter::new();     ctr.count(13);     ctr.count(14);     ctr.count(16);     ctr.count(14);     ctr.count(14);     ctr.count(11);      for i in 10..20 {         println!(\"saw {} values equal to {}\", ctr.times_seen(i), i);     }      let mut strctr = Counter::new();     strctr.count(\"apple\");     strctr.count(\"orange\");     strctr.count(\"apple\");     println!(\"got {} apples\", strctr.times_seen(\"apple\")); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043e\u0431\u0449\u0438\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f \u043a\u043b\u044e\u0447\u0430<\/li>\n<li>\u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u0435 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>struct Counter&lt;T><\/code> \u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/li>\n<li>\u043e\u0431\u0449\u0438\u0439 \u0442\u0438\u043f \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c 2 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u0430: \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0438, \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u0437 <code>std::hash<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">\/\/ ... use std::hash::Hash;  struct Counter&lt;T: Eq + Hash> {     values: HashMap&lt;T, u64>, }  impl&lt;T: Eq + Hash> Counter&lt;T> {     \/\/ ...      fn count(&amp;mut self, value: T) {         \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435.         \/\/ \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c `or_insert(0)`         *self.values.entry(value).or_default() += 1;     }      fn times_seen(&amp;self, value: T) -> u64 {         self.values.get(&amp;value).copied().unwrap_or_default()     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<h2 id=\"treyty-predostavlyaemye-standartnoy-bibliotekoy-rust\">\u0422\u0440\u0435\u0439\u0442\u044b, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Rust<\/h2>\n<p>  <\/p>\n<p>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430.<\/p>\n<p>  <\/p>\n<p><strong>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u0442\u0440\u0435\u0439\u0442\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u0438\u043f\u0430\u0445, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u044d\u0442\u0438 \u0442\u0440\u0435\u0439\u0442\u044b.<\/p>\n<p>  <\/p>\n<p><em>PartialEq \u0438 Eq<\/em><\/p>\n<p>  <\/p>\n<p><code>PartialEq<\/code> \u2014 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0439 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (partial equivalence relation), \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>eq()<\/code> \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>ne()<\/code>. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438 <code>==<\/code> \u0438 <code>!=<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Key {     id: u32,     metadata: Option&lt;String>, }  impl PartialEq for Key {     fn eq(&amp;self, other: &amp;Self) -> bool {         self.id == other.id     } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>Eq<\/code> \u2014 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (\u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0432\u043d\u043e\u0435, \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0438 \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u043e\u0435), \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0435 <code>PartialEq<\/code>. \u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u043d\u0443\u044e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>Eq<\/code> \u043a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u0440\u0435\u0439\u0442 (trait bound).<\/p>\n<p>  <\/p>\n<p><code>PartialEq<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0430 <code>Eq<\/code> \u043d\u0435\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0432\u043d\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">struct Key {     id: u32,     metadata: Option&lt;String>, }  impl PartialEq&lt;u32> for Key {     fn eq(&amp;self, other: &amp;u32) -> bool {         self.id == *other     } }<\/code><\/pre>\n<p>  <\/p>\n<p><em>PartialOrd \u0438 Ord<\/em><\/p>\n<p>  <\/p>\n<p><code>PartialOrd<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a (partial ordering), \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>partial_cmp()<\/code>. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <code>&lt;<\/code>, <code>&lt;=<\/code>, <code>>=<\/code> \u0438 <code>><\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::cmp::Ordering;  #[derive(Eq, PartialEq)] struct Citation {     author: String,     year: u32, }  impl PartialOrd for Citation {     fn partial_cmp(&amp;self, other: &amp;Self) -> Option&lt;Ordering> {         match self.author.partial_cmp(&amp;other.author) {             Some(Ordering::Equal) => self.year.partial_cmp(&amp;other.year),             author_ord => author_ord,         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>Ord<\/code> \u2014 \u044d\u0442\u043e \u0442\u043e\u0442\u0430\u043b\u044c\u043d\u044b\u0439 (total) \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>cmp()<\/code>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u043c <code>Ordering<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u0438 \u0442\u0440\u0435\u0439\u0442\u044b \u0447\u0430\u0449\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 (<code>derive<\/code>), \u0447\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<p>  <\/p>\n<p><strong>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/strong><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0439\u0442\u0430 <a href=\"https:\/\/doc.rust-lang.org\/std\/ops\/index.html\">std::ops<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug, Copy, Clone)] struct Point {     x: i32,     y: i32, }  impl std::ops::Add for Point {     type Output = Self;      fn add(self, other: Self) -> Self {         Self { x: self.x + other.x, y: self.y + other.y }     } }  fn main() {     let p1 = Point { x: 10, y: 20 };     let p2 = Point { x: 100, y: 200 };     println!(\"{:?} + {:?} = {:?}\", p1, p2, p1 + p2); }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>Add<\/code> \u0434\u043b\u044f <code>&amp;Point<\/code>. \u0412 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c?<br \/> \n<ul>\n<li>\u041e\u0442\u0432\u0435\u0442: <code>Add::add()<\/code> \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 <code>self<\/code>. \u0415\u0441\u043b\u0438 \u0442\u0438\u043f <code>T<\/code>, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440, \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>Copy<\/code> (\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u043c), \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f <code>&amp;T<\/code>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435<\/li>\n<\/ul>\n<\/li>\n<li>\u041f\u043e\u0447\u0435\u043c\u0443 <code>Output<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c? \u041c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0442\u0438\u043f\u0430 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430?<br \/> \n<ul>\n<li>\u041a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043e\u0442\u0432\u0435\u0442: \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0438\u043f\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c, \u0430 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (<code>Output<\/code>) \u2014 \u0442\u0435\u043c, \u043a\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u0440\u0435\u0439\u0442<\/li>\n<\/ul>\n<\/li>\n<li>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>Add<\/code> \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>impl Add&lt;(i32, i32)> for Point<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043a\u043e\u0440\u0442\u0435\u0436 \u0432 <code>Point<\/code><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>From \u0438 Into<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0435\u0439\u0442\u044b <a href=\"https:\/\/doc.rust-lang.org\/std\/convert\/trait.From.html\">From<\/a> \u0438 <a href=\"https:\/\/doc.rust-lang.org\/std\/convert\/trait.Into.html\">Into<\/a>, \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let s = String::from(\"hello\");     let addr = std::net::Ipv4Addr::from([127, 0, 0, 1]);     let one = i16::from(true);     let bigger = i32::from(123_i16);     println!(\"{s}, {addr}, {one}, {bigger}\"); }<\/code><\/pre>\n<p>  <\/p>\n<p><code>Into<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>From<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let s: String = \"hello\".into();     let addr: std::net::Ipv4Addr = [127, 0, 0, 1].into();     let one: i16 = true.into();     let bigger: i32 = 123_i16.into();     println!(\"{s}, {addr}, {one}, {bigger}\"); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432<\/strong><\/p>\n<p>  <\/p>\n<p><code>Rust<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0435\u044f\u0432\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435) \u0442\u0438\u043f\u043e\u0432 (casting), \u0442\u0430\u043a \u0438 \u044f\u0432\u043d\u043e\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let value: i64 = 1000;     println!(\"as u16: {}\", value as u16);     println!(\"as i16: {}\", value as i16);     println!(\"as u8: {}\", value as u8); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b <code>as<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 <code>Rust<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435\u043c\u0443 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u043a\u0430 \u0438\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043a \u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0442\u0438\u043f\u0443.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as<\/code> \u2014 \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043c\u0435\u043b\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0438\u043b\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0446\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0443\u0441\u0435\u0447\u0435\u043d\u0438\u0435 (unconditional truncation) (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0431\u043e\u0440 \u043d\u0438\u0436\u043d\u0438\u0445 32 \u0431\u0438\u0442\u043e\u0432 <code>u64<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>as u32<\/code>, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0431\u0438\u0442\u0430\u0445).<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 <code>u32<\/code> \u0432 <code>u64<\/code>), \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>From<\/code> \u0438\u043b\u0438 <code>Into<\/code>. \u0414\u043b\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b <code>TryFrom<\/code> \u0438 <code>TryInto<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<p>  <\/p>\n<p><strong>Read \u0438 Write<\/strong><\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/doc.rust-lang.org\/std\/io\/trait.Read.html\">Read<\/a> \u0438 <a href=\"https:\/\/doc.rust-lang.org\/std\/io\/trait.BufRead.html\">BufRead<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 (sources) <code>u8<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::io::{BufRead, BufReader, Read, Result};  fn count_lines&lt;R: Read>(reader: R) -> usize {     let buf_reader = BufReader::new(reader);     buf_reader.lines().count() }  \/\/ \u0417\u0434\u0435\u0441\u044c `Result&lt;T>` \u0438\u0437 `std::io` == `Result&lt;T, std::io::Error>` fn main() -> Result&lt;()> {     let slice: &amp;[u8] = b\"foo\\nbar\\nbaz\\n\";     println!(\"\u0441\u0442\u0440\u043e\u043a \u0432 \u0441\u0440\u0435\u0437\u0435: {}\", count_lines(slice));      let file = std::fs::File::open(std::env::current_exe()?)?;     println!(\"\u0441\u0442\u0440\u043e\u043a \u0432 \u0444\u0430\u0439\u043b\u0435: {}\", count_lines(file));     Ok(()) }<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/doc.rust-lang.org\/std\/io\/trait.Write.html\">Write<\/a>, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u043e\u0432 (sinks) <code>u8<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::io::{Result, Write};  fn log&lt;W: Write>(writer: &amp;mut W, msg: &amp;str) -> Result&lt;()> {     writer.write_all(msg.as_bytes())?;     writer.write_all(\"\\n\".as_bytes()) }  fn main() -> Result&lt;()> {     let mut buffer = Vec::new();     log(&amp;mut buffer, \"Hello\")?;     log(&amp;mut buffer, \"World\")?;     println!(\"{:?}\", buffer);     Ok(()) }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0422\u0440\u0435\u0439\u0442 Default<\/strong><\/p>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u0439\u0442 <a href=\"https:\/\/doc.rust-lang.org\/std\/default\/trait.Default.html\">Default<\/a> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug, Default)] struct Derived {     x: u32,     y: String,     z: Implemented, }  #[derive(Debug)] struct Implemented(String);  impl Default for Implemented {     fn default() -> Self {         Self(\"\u0418\u0432\u0430\u043d \u041f\u0435\u0442\u0440\u043e\u0432\".into())     } }  fn main() {     let default_struct = Derived::default();     println!(\"{default_struct:#?}\");      let almost_default_struct =         Derived { y: \"Y \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430!\".into(), ..Derived::default() };     println!(\"{almost_default_struct:#?}\");      let nothing: Option&lt;Derived> = None;     println!(\"{:#?}\", nothing.unwrap_or_default()); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Default<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0442\u0430\u043a \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>derive<\/code><\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<br \/> \n<ul>\n<li>\u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c <code>Default<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b <code>Rust<\/code> \u0447\u0430\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 <code>Default<\/code> \u0441 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 (<code>0<\/code>, <code>\"\"<\/code> \u0438 \u0442.\u0434.)<\/li>\n<li>\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 <code>Default<\/code><\/li>\n<li>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>Rust<\/code> \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c <code>Default<\/code>, \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442<\/li>\n<li>\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>..<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/doc.rust-lang.org\/book\/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax\">\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f<\/strong><\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f (closures) \u0438\u043b\u0438 \u043b\u044f\u043c\u0431\u0434\u0430-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0442\u0438\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0430\u0442\u044c \u0438\u043c\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b <a href=\"https:\/\/doc.rust-lang.org\/std\/ops\/trait.Fn.html\">Fn<\/a>, <a href=\"https:\/\/doc.rust-lang.org\/std\/ops\/trait.FnMut.html\">FnMut<\/a> \u0438 <a href=\"https:\/\/doc.rust-lang.org\/std\/ops\/trait.FnOnce.html\">FnOnce<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn apply_with_log(func: impl FnOnce(i32) -> i32, input: i32) -> i32 {     println!(\"\u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 {input}\");     func(input) }  fn main() {     let add_3 = |x| x + 3;     println!(\"add_3: {}\", apply_with_log(add_3, 10));     println!(\"add_3: {}\", apply_with_log(add_3, 20));      let mut v = Vec::new();     let mut accumulate = |x: i32| {         v.push(x);         v.iter().sum::&lt;i32>()     };     println!(\"accumulate: {}\", apply_with_log(&amp;mut accumulate, 4));     println!(\"accumulate: {}\", apply_with_log(&amp;mut accumulate, 5));      let multiply_sum = |x| x * v.into_iter().sum::&lt;i32>();     println!(\"multiply_sum: {}\", apply_with_log(multiply_sum, 3)); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>Fn<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>add_3<\/code>) \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442. \u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/li>\n<li><code>FnMut<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>accumulate<\/code>) \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0415\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u043d\u043e \u043d\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/li>\n<li><code>FnOnce<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>multiply_sum<\/code>) \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/li>\n<li><code>FnMut<\/code> \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0442\u0438\u043f (\u043f\u043e\u0434\u0442\u0440\u0435\u0439\u0442 \u2014 subtrait) <code>FnOnce<\/code>. <code>Fn<\/code> \u2014 \u044d\u0442\u043e \u043f\u043e\u0434\u0442\u0438\u043f <code>FnMut<\/code> \u0438 <code>FnOnce<\/code>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>FnMut<\/code> \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f <code>FnOnce<\/code>, \u0438 <code>Fn<\/code> \u0442\u0430\u043c, \u0433\u0434\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f <code>FnMut<\/code> \u0438\u043b\u0438 <code>FnOnce<\/code><\/li>\n<li>\u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0440\u0430\u0442\u044c <code>FnOnce<\/code>, \u0437\u0430\u0442\u0435\u043c <code>FnMut<\/code> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 <code>Fn<\/code> \u043a\u0430\u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u0442\u0438\u043f<\/li>\n<li>\u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 <code>Fn<\/code><\/li>\n<li>\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435. \u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>move<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"rust\">fn make_greeter(prefix: String) -> impl Fn(&amp;str) {     return move |name| println!(\"{} {}\", prefix, name); }  fn main() {     let hi = make_greeter(\"\u043f\u0440\u0438\u0432\u0435\u0442\".to_string());     hi(\"\u0432\u0441\u0435\u043c\"); }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0423\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435: ROT13<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0438 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0448\u0438\u0444\u0440 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/ROT13\">&#171;ROT13&#187;<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u043d\u044f\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b <code>ASCII<\/code>, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c <code>UTF-8<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::io::Read;  struct RotDecoder&lt;R: Read> {     input: R,     rot: u8, }  impl&lt;R: Read> Read for RotDecoder&lt;R> {     fn read(&amp;mut self, buf: &amp;mut [u8]) -> std::io::Result&lt;usize> {         todo!(\"\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0439 \u043c\u0435\u043d\u044f\")     } }  fn main() {     let mut rot =         RotDecoder { input: \"Gb trg gb gur bgure fvqr!\".as_bytes(), rot: 13 };     let mut result = String::new();     \/\/ `read_to_string()` \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 `read()` \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443     rot.read_to_string(&amp;mut result).unwrap();     println!(\"{}\", result); }  #[cfg(test)] mod test {     use super::*;      #[test]     fn joke() {         let mut rot =             RotDecoder { input: \"Gb trg gb gur bgure fvqr!\".as_bytes(), rot: 13 };         let mut result = String::new();         rot.read_to_string(&amp;mut result).unwrap();         assert_eq!(&amp;result, \"To get to the other side!\");     }      #[test]     fn binary() {         let input: Vec&lt;u8> = (0..=255u8).collect();         let mut rot = RotDecoder::&lt;&amp;[u8]> { input: input.as_ref(), rot: 13 };         let mut buf = [0u8; 256];         assert_eq!(rot.read(&amp;mut buf).unwrap(), 256);         for i in 0..=255 {             if input[i] != buf[i] {                 assert!(input[i].is_ascii_alphabetic());                 assert!(buf[i].is_ascii_alphabetic());             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"rust\">impl&lt;R: Read> Read for RotDecoder&lt;R> {     fn read(&amp;mut self, buf: &amp;mut [u8]) -> std::io::Result&lt;usize> {         \/\/ \u0427\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0443\u0444\u0435\u0440         let size = self.input.read(buf)?;         \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0430\u0439\u0442\u044b         for b in &amp;mut buf[..size] {             \/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u043a\u0432\u044b \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430             if b.is_ascii_alphabetic() {                 \/\/ \u0411\u0430\u0437\u0430                 let base = if b.is_ascii_uppercase() { 'A' } else { 'a' } as u8;                 \/\/ \u0421\u0434\u0432\u0438\u0433\u0430\u0435\u043c \u043d\u0430 `rot` \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 26 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0443\u043a\u0432 \u0432 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0435)                 *b = (*b - base + self.rot) % 26 + base;             }         }         \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \"\u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435\" \u0431\u0430\u0439\u0442\u044b         Ok(size)     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043a\u043e\u043d\u0435\u0446 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430.<\/p>\n<p>  <\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/doc.rust-lang.ru\/book\">\u041a\u043d\u0438\u0433\u0430\/\u0443\u0447\u0435\u0431\u043d\u0438\u043a \u043f\u043e Rust<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435) \u2014 \u0433\u043b\u0430\u0432\u044b 6, 8, 10, 13, 17 \u0438 18<\/li>\n<li><a href=\"https:\/\/github.com\/rust-lang\/rustlings\">rustlings<\/a> \u2014 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f 04-06, 09, 11, 12, 14 \u0438 15<\/li>\n<li><a href=\"https:\/\/doc.rust-lang.ru\/stable\/rust-by-example\/\">Rust \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445<\/a> (\u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435) \u2014 5, 6, 14, 16, 19 \u0438 20<\/li>\n<li><a href=\"https:\/\/practice.rs\/why-exercise.html\">Rust by practice<\/a> \u2014 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f 8-12 \u0438 18<\/li>\n<\/ul>\n<p>  <\/p>\n<p>Happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/timeweb.cloud\/vds-vps?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/b5\/pj\/of\/b5pjofdoxth14ro-rjsrn7sbmiy.png\" data-src=\"https:\/\/habrastorage.org\/webt\/b5\/pj\/of\/b5pjofdoxth14ro-rjsrn7sbmiy.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/794941\/\"> https:\/\/habr.com\/ru\/articles\/794941\/<\/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\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/fj\/yi\/qn\/fjyiqnduv3l-rdgxnbu_t_qpgxk.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/fj\/yi\/qn\/fjyiqnduv3l-rdgxnbu_t_qpgxk.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>Hello world!<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0432\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u043f\u043e <a href=\"https:\/\/www.rust-lang.org\/ru\/\">Rust<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/790556\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/796567\/\">\u0422\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/801201\/\">\u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/companies\/timeweb\/articles\/802609\/\">\u0411\u043e\u043d\u0443\u0441<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/my-js.org\/docs\/guide\/rust\/\">\u0414\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 <a href=\"https:\/\/google.github.io\/comprehensive-rust\/index.html\">Comprehensive Rust<\/a> \u2014 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043f\u043e <code>Rust<\/code> \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>Android<\/code> \u0432 <code>Google<\/code> \u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0432\u043b\u0430\u0434\u0435\u044e\u0442 \u043b\u044e\u0431\u044b\u043c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0415\u0449\u0435 \u0440\u0430\u0437: \u044d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043e \u043d\u0430 \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u043e\u0434\u0438\u0442\u044c ?<\/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-368689","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368689","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=368689"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368689\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}