{"id":348710,"date":"2023-06-13T15:01:26","date_gmt":"2023-06-13T15:01:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348710"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348710","title":{"rendered":"<span>\u0420\u0436\u0430\u0432\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/67e\/679\/073\/67e6790734fb7455b5dccd58e1fcf2c8.png\" alt=\"\u041c\u0435\u0440\u0442\u0432\u0430\u044f \u0444\u0438\u0447\u0430\" title=\"\u041c\u0435\u0440\u0442\u0432\u0430\u044f \u0444\u0438\u0447\u0430\" width=\"900\" height=\"1200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/67e\/679\/073\/67e6790734fb7455b5dccd58e1fcf2c8.png\"\/><\/p>\n<div><figcaption>\u041c\u0435\u0440\u0442\u0432\u0430\u044f \u0444\u0438\u0447\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u041f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443, \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0434\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 <em>prod-ready<\/em> \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, <code>Rc<\/code>, <code>Box<\/code> \u0438 \u0442\u0434. &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<code>no_std<\/code>.<\/p>\n<h2>\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430<\/h2>\n<p>\u041c\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u041e\u041e\u041f \u0440\u0430\u0437\u043d\u0438\u0442\u0441\u044f, \u043a\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0442\u0438\u0432 \u043d\u0435\u0433\u043e, \u043a\u0442\u043e-\u0442\u043e (\u043a\u0430\u043a \u0432 UI) \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0441\u0442\u0430\u0432\u044f\u0442 \u043a\u0440\u0435\u0441\u0442 \u043d\u0430 \u0440\u0436\u0430\u0432\u043e\u043c. \u0412 Rust Book, \u0432 <a href=\"https:\/\/doc.rust-lang.ru\/book\/ch17-01-what-is-oo.html\" rel=\"noopener noreferrer nofollow\">17 \u0433\u043b\u0430\u0432\u0435<\/a> \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442: <em>&#171;\u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u0442\u043e Rust \u0442\u0430\u043a\u0438\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u043b\u044f \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u0430&#187;<\/em>.<em> <\/em>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u043b\u043e \u0431\u044b \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0433\u0434\u0435 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 <em>Middleware <\/em>\u0438 <em>Response<\/em> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0442\u043e\u043d\u043d\u0443 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Don%E2%80%99t_repeat_yourself\" rel=\"noopener noreferrer nofollow\">DRY<\/a>; \u043b\u0438\u0431\u043e \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043a\u0443\u0447\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h2>\u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438<\/h2>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0442\u043e\u043c\u0438\u0442\u044c, \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e &#8212; \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438 \u043d\u0430\u0447\u043d\u0443 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435:<\/p>\n<pre><code class=\"rust\">trait Animal { \u00a0 \u00a0 type Parent: Animal;  \u00a0 \u00a0 fn say(text: &amp;'static str) { \u00a0 \u00a0 \u00a0 \u00a0 Self::Parent::say(text); \u00a0 \u00a0 } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0439\u0442\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0437\u0431\u0438\u0442\u043e\u0439 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u041e\u041e\u041f (\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f)<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u0418 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"rust\">trait Animal {     type Parent: Animal;      fn say(text: &amp;'static str) {         Self::Parent::say(text);     } }   struct Dog;  impl Animal for Dog {     type Parent = Self;      fn say(text: &amp;'static str) {         println!(\"Woof: {text}\");     } }   impl Animal for Cat {     type Parent = Self;      fn say(text: &amp;'static str) {         println!(\"Meow: {text}\");     } }   struct Komaru;  impl Animal for Komaru {     type Parent = Cat; }   fn soft_sayer&lt;A>(text: &amp;'static str)     where A: Animal {         A::say(text) }  fn strong_sayer&lt;A>(text: &amp;'static str)     where A: Animal&lt;Parent = Cat> {         A::say(text) }   fn main() {     soft_sayer::&lt;Komaru>(\"hello\");     strong_sayer::&lt;Komaru>(\"bonjur\");      Komaru::say(\"\u041c\u0435\u043d\u044f \u0435\u0434\u044f\u0442 \u0441 \u0441\u043e\u043b\u044c\u044e!\") }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Dog<\/code> \u0438 <code>Cat<\/code>, \u0431\u0435\u0437 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0442\u0438\u043f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>type Parent = Self<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0438 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0443\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0438\u0445. \u0412\u0430\u0436\u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0438\u0437-\u0437\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0441 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439: <code>A: Animal<\/code> &#8212; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u0441 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0442\u0440\u0435\u0439\u0442\u043e\u043c, <code>A: Animal&lt;Parent = Cat><\/code> &#8212; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (\u0434\u0430 \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445) \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0443 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u044d\u0442\u043e \u0432 \u0443\u043c\u0435, \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f <code>Self::Parent <\/code>\u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0432\u0435\u0441\u0438\u0442\u044c \u043b\u043e\u0433\u0430\u043c\u0438\/\u0442\u0440\u0430\u0441\u0435\u0440\u0430\u043c\u0438\/\u0442\u0430\u0439\u043c\u0435\u0440\u043e\u043c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u043a\u0440\u044b\u0442\u0443\u044e \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u043d\u0438\u043a\u0443 \u0441 <code>Stack overflow<\/code>. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u043d\u0438\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u044f\u0441\u044c, \u0447\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c \u0434\u043e \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h2>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u0432\u0435\u0440\u0441\u0438\u044e, \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u043a\u043e\u0434 \u0438 \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0439\u0442\u043e\u0432. \u041d\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">trait BaseAnimal {     type Parent: BaseAnimal;      fn parent(&amp;self) -> &amp;Self::Parent;          fn say(&amp;self, text: &amp;'static str) {         self.parent().say(text)     } }   struct Animal {     prefix: &amp;'static str, }  impl Animal {     fn new(prefix: &amp;'static str) -> Self {         Self { prefix }     } }  impl BaseAnimal for Animal {     type Parent = Self;      fn parent(&amp;self) -> &amp;Self::Parent {         self     }      fn say(&amp;self, text: &amp;'static str) {         println!(\"{}: {text}\", self.prefix);     } }   struct Cat(Animal);  impl Cat {     fn new() -> Self {         Self(Animal::new(\"Meow\"))     } }  impl BaseAnimal for Cat {     type Parent = Animal;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     } }   struct Winky(Cat);  impl Default for Winky {     fn default() -> Self {         Self(Cat::new())     } }  impl BaseAnimal for Winky {     type Parent = Cat;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     } }   struct Komaru(Cat);  impl Default for Komaru {     fn default() -> Self {         Self(Cat::new())     } }  impl BaseAnimal for Komaru {     type Parent = Cat;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     }      fn say(&amp;self, _: &amp;'static str) {         println!(\"\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0430\u0432\u0442\u043e\u0440\u0430 \u043a\u0432\u0430\u0437\u0437\u043e\u043c!\");     } }   fn unsized_sayer&lt;A>()     where A: Default + BaseAnimal {         A::default().say(\"hello\"); }  fn sized_sayer(animal: impl BaseAnimal&lt;Parent = Cat>) {     animal.say(\"hello\"); }   fn main() {     unsized_sayer::&lt;Winky>();      sized_sayer(Komaru::default()); }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>parent<\/code> \u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0432\u0438\u0434\u0435 <code>Animal<\/code>, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0437\u0432\u0443\u0447\u0438\u0432\u0430\u043d\u0438\u044f. <code>parent<\/code> \u0441\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>Cat<\/code> c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Animal<\/code> \u0438 \u0431\u0438\u043b\u0434\u0435\u0440\u043e\u043c \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 (\u0434\u043b\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0434\u0430\u043b\u044c\u0448\u0435). \u041f\u0440\u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>Animal<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043c\u0435\u0442\u043e\u0434 \u043e\u0437\u0432\u0443\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0442\u044f\u043d\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>Winky<\/code> \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Cat<\/code>. \u041a\u0430\u043a \u0438 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 \u0432\u044b\u0448\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043f\u0440\u0438\u0447\u0435\u043c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e <code>Cat<\/code> \u0443\u0436\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 <code>Animal<\/code>, \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>Komaru<\/code>, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>type Parent = Self<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>Parent<\/code>, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0443\u0431\u0440\u0430\u043b\u0438 <code>Cat<\/code> \u0443 <code>Komaru<\/code>, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u044b \u0435\u0435 \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b!<\/p>\n<\/li>\n<\/ol>\n<h2>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u0435\u0440\u0445\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0436\u0430\u0432\u043e\u043c, \u043d\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u0443\u043d\u0434\u044b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c:<\/p>\n<pre><code class=\"rust\">trait Animal&lt;Parent: Animal&lt;Parent>> {     fn say(text: &amp;'static str) {         Parent::say(text);     } }   struct Cat;  impl Animal&lt;Self> for Cat {     fn say(text: &amp;'static str) {         println!(\"Meow: {text}\");     } }   struct Dog;  impl Animal&lt;Self> for Dog {     fn say(text: &amp;'static str) {         println!(\"Woof: {text}\");     } }   struct Kokoa;  impl Animal&lt;Cat> for Kokoa {} impl Animal&lt;Dog> for Kokoa {}   fn cat_sayer&lt;A>(text: &amp;'static str)      where A: Animal&lt;Cat> {         A::say(text); }  fn dog_sayer&lt;A>(text: &amp;'static str)      where A: Animal&lt;Dog> {         A::say(text); }   fn main() {     cat_sayer::&lt;Kokoa>(\"hello\");     dog_sayer::&lt;Kokoa>(\"bonjur\");      &lt;Kokoa as Animal&lt;Cat>>         ::say(\"\u0422\u0430\u043a\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0441\u043e\u043b\u044c\u044e!\"); }<\/code><\/pre>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0441 \u043e\u0434\u043d\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c, \u0432\u043c\u0435\u0441\u0442\u043e <code>type Parent<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0443\u043d\u0434, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u043c\u0443 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u0431\u044b\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438<code>Cat<\/code> \u0438 <code>Dog<\/code>. \u0423\u0432\u044b, \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0443\u043d\u0434\u043e\u0432 \u0443\u0436\u0435 \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">trait BaseAnimal&lt;Parent: BaseAnimal&lt;Animal>> {     fn parent(&amp;self) -> &amp;Parent;      fn say(&amp;self, text: &amp;'static str) {         self.parent().say(text);     } }   struct Animal {     prefix: &amp;'static str, }  impl Animal {     fn new(prefix: &amp;'static str) -> Self {         Self { prefix }     } }  impl BaseAnimal&lt;Self> for Animal {     fn parent(&amp;self) -> &amp;Self {         &amp;self     }      fn say(&amp;self, text: &amp;'static str) {         println!(\"{}: {text}\", self.prefix);     } }   struct Cat(Animal);  impl Default for Cat {     fn default() -> Self {         Self(Animal::new(\"Meow\"))     } }  impl BaseAnimal&lt;Animal> for Cat {     fn parent(&amp;self) -> &amp;Animal {         &amp;self.0     } }   struct Dog(Animal);  impl Default for Dog {     fn default() -> Self {         Self(Animal::new(\"Woof\"))     } }  impl BaseAnimal&lt;Animal> for Dog {     fn parent(&amp;self) -> &amp;Animal {         &amp;self.0     } }   struct Komaru(Cat, Dog);  impl Default for Komaru {     fn default() -> Self {         Self(Cat::default(), Dog::default())     } }  impl BaseAnimal&lt;Cat> for Komaru {     fn parent(&amp;self) -> &amp;Cat {         &amp;self.0     } }  impl BaseAnimal&lt;Dog> for Komaru {     fn parent(&amp;self) -> &amp;Dog {         &amp;self.1     } }   fn unsized_cat_sayer&lt;A>()     where A: Default + BaseAnimal&lt;Cat> {         A::default().say(\"hello\"); }  fn sized_cat_sayer(animal: &amp;impl BaseAnimal&lt;Cat>) {     animal.say(\"hello\"); }   fn main() {     let komaru = Komaru::default();      unsized_cat_sayer::&lt;Komaru>();     sized_cat_sayer(&amp;komaru);      &lt;dyn BaseAnimal&lt;Cat>>         ::say(&amp;komaru, \"\u0427\u0442\u043e \u044f \u0442\u0430\u043a\u043e\u0435...\"); } <\/code><\/pre>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0439, \u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0443\u043d\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 <code>type Parent<\/code>. \u0412\u0430\u0436\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u0430. \u041f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0438 \u043d\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438.<\/p>\n<h2>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438<\/h2>\n<p>\u0412\u0441\u0435\u0433\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u043e\u0434 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u043e\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0437\u0430\u0431\u0430\u0432\u043d\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0440\u0436\u0430\u0432\u043e\u0433\u043e \u0438 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0435\u0449\u0435 \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0432\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0448\u043b\u043e \u043f\u043e\u043b\u0433\u043e\u0434\u0430 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u0438 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u0436\u0438\u0437\u043d\u0438, \u0438 \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043e\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043c\u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u043c\u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0430 \u043a\u043e\u0434 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043d\u0435\u0441\u0435\u043d \u0432 Rust Book <s>\u0441 \u0432\u044b\u0434\u0430\u0447\u0435\u0439 \u043c\u043d\u0435 \u0432\u0435\u0447\u043d\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0441\u0442\u0432\u0430 \u0432 Rust Foundation<\/s>. \u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439, \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u0442\u0438\u043f\u0430 MVC, \u0438\u043b\u0438 \u043d\u0430 \u0438\u0434\u0435\u044f\u0445 \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/741458\/\"> https:\/\/habr.com\/ru\/articles\/741458\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>\u041c\u0435\u0440\u0442\u0432\u0430\u044f \u0444\u0438\u0447\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u041f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443, \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0434\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 <em>prod-ready<\/em> \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, <code>Rc<\/code>, <code>Box<\/code> \u0438 \u0442\u0434. &#8212; \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<code>no_std<\/code>.<\/p>\n<h2>\u0418\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430<\/h2>\n<p>\u041c\u043d\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u041e\u041e\u041f \u0440\u0430\u0437\u043d\u0438\u0442\u0441\u044f, \u043a\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0442\u0438\u0432 \u043d\u0435\u0433\u043e, \u043a\u0442\u043e-\u0442\u043e (\u043a\u0430\u043a \u0432 UI) \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u0441\u0442\u0430\u0432\u044f\u0442 \u043a\u0440\u0435\u0441\u0442 \u043d\u0430 \u0440\u0436\u0430\u0432\u043e\u043c. \u0412 Rust Book, \u0432 <a href=\"https:\/\/doc.rust-lang.ru\/book\/ch17-01-what-is-oo.html\" rel=\"noopener noreferrer nofollow\">17 \u0433\u043b\u0430\u0432\u0435<\/a> \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442: <em>&#171;\u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u0442\u043e Rust \u0442\u0430\u043a\u0438\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u043b\u044f \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u0430&#187;<\/em>.<em> <\/em>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u043b\u043e \u0431\u044b \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0433\u0434\u0435 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 <em>Middleware <\/em>\u0438 <em>Response<\/em> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0442\u043e\u043d\u043d\u0443 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Don%E2%80%99t_repeat_yourself\" rel=\"noopener noreferrer nofollow\">DRY<\/a>; \u043b\u0438\u0431\u043e \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043a\u0443\u0447\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h2>\u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438<\/h2>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0442\u043e\u043c\u0438\u0442\u044c, \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e &#8212; \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438 \u043d\u0430\u0447\u043d\u0443 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435:<\/p>\n<pre><code class=\"rust\">trait Animal { \u00a0 \u00a0 type Parent: Animal;  \u00a0 \u00a0 fn say(text: &amp;'static str) { \u00a0 \u00a0 \u00a0 \u00a0 Self::Parent::say(text); \u00a0 \u00a0 } }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0439\u0442\u0430 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u0437\u0431\u0438\u0442\u043e\u0439 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u041e\u041e\u041f (\u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f)<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u0418 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0436\u0438\u0432\u043e\u0442\u043d\u043e\u0433\u043e:<\/p>\n<pre><code class=\"rust\">trait Animal {     type Parent: Animal;      fn say(text: &amp;'static str) {         Self::Parent::say(text);     } }   struct Dog;  impl Animal for Dog {     type Parent = Self;      fn say(text: &amp;'static str) {         println!(\"Woof: {text}\");     } }   impl Animal for Cat {     type Parent = Self;      fn say(text: &amp;'static str) {         println!(\"Meow: {text}\");     } }   struct Komaru;  impl Animal for Komaru {     type Parent = Cat; }   fn soft_sayer&lt;A>(text: &amp;'static str)     where A: Animal {         A::say(text) }  fn strong_sayer&lt;A>(text: &amp;'static str)     where A: Animal&lt;Parent = Cat> {         A::say(text) }   fn main() {     soft_sayer::&lt;Komaru>(\"hello\");     strong_sayer::&lt;Komaru>(\"bonjur\");      Komaru::say(\"\u041c\u0435\u043d\u044f \u0435\u0434\u044f\u0442 \u0441 \u0441\u043e\u043b\u044c\u044e!\") }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>Dog<\/code> \u0438 <code>Cat<\/code>, \u0431\u0435\u0437 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0442\u0438\u043f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>type Parent = Self<\/code>, \u0447\u0442\u043e\u0431\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0438 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u0443\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0438\u0445. \u0412\u0430\u0436\u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0438\u0437-\u0437\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430 \u0441 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439: <code>A: Animal<\/code> &#8212; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u0441 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0442\u0440\u0435\u0439\u0442\u043e\u043c, <code>A: Animal&lt;Parent = Cat><\/code> &#8212; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (\u0434\u0430 \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445) \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0443 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u044d\u0442\u043e \u0432 \u0443\u043c\u0435, \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f <code>Self::Parent <\/code>\u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0432\u0435\u0441\u0438\u0442\u044c \u043b\u043e\u0433\u0430\u043c\u0438\/\u0442\u0440\u0430\u0441\u0435\u0440\u0430\u043c\u0438\/\u0442\u0430\u0439\u043c\u0435\u0440\u043e\u043c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u043a\u0440\u044b\u0442\u0443\u044e \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u043d\u0438\u043a\u0443 \u0441 <code>Stack overflow<\/code>. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u043d\u0438\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u044f\u0441\u044c, \u0447\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c \u0434\u043e \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/h2>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u0432\u0435\u0440\u0441\u0438\u044e, \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u043a\u043e\u0434 \u0438 \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0440\u0435\u0439\u0442\u043e\u0432. \u041d\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">trait BaseAnimal {     type Parent: BaseAnimal;      fn parent(&amp;self) -> &amp;Self::Parent;          fn say(&amp;self, text: &amp;'static str) {         self.parent().say(text)     } }   struct Animal {     prefix: &amp;'static str, }  impl Animal {     fn new(prefix: &amp;'static str) -> Self {         Self { prefix }     } }  impl BaseAnimal for Animal {     type Parent = Self;      fn parent(&amp;self) -> &amp;Self::Parent {         self     }      fn say(&amp;self, text: &amp;'static str) {         println!(\"{}: {text}\", self.prefix);     } }   struct Cat(Animal);  impl Cat {     fn new() -> Self {         Self(Animal::new(\"Meow\"))     } }  impl BaseAnimal for Cat {     type Parent = Animal;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     } }   struct Winky(Cat);  impl Default for Winky {     fn default() -> Self {         Self(Cat::new())     } }  impl BaseAnimal for Winky {     type Parent = Cat;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     } }   struct Komaru(Cat);  impl Default for Komaru {     fn default() -> Self {         Self(Cat::new())     } }  impl BaseAnimal for Komaru {     type Parent = Cat;      fn parent(&amp;self) -> &amp;Self::Parent {         &amp;self.0     }      fn say(&amp;self, _: &amp;'static str) {         println!(\"\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0442\u0435 \u0430\u0432\u0442\u043e\u0440\u0430 \u043a\u0432\u0430\u0437\u0437\u043e\u043c!\");     } }   fn unsized_sayer&lt;A>()     where A: Default + BaseAnimal {         A::default().say(\"hello\"); }  fn sized_sayer(animal: impl BaseAnimal&lt;Parent = Cat>) {     animal.say(\"hello\"); }   fn main() {     unsized_sayer::&lt;Winky>();      sized_sayer(Komaru::default()); }<\/code><\/pre>\n<ol>\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>parent<\/code> \u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0432\u0438\u0434\u0435 <code>Animal<\/code>, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0437\u0432\u0443\u0447\u0438\u0432\u0430\u043d\u0438\u044f. <code>parent<\/code> \u0441\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>Cat<\/code> c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Animal<\/code> \u0438 \u0431\u0438\u043b\u0434\u0435\u0440\u043e\u043c \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 (\u0434\u043b\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0434\u0430\u043b\u044c\u0448\u0435). \u041f\u0440\u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>Animal<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043c\u0435\u0442\u043e\u0434 \u043e\u0437\u0432\u0443\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0442\u044f\u043d\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c <code>Winky<\/code> \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Cat<\/code>. \u041a\u0430\u043a \u0438 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 \u0432\u044b\u0448\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043f\u0440\u0438\u0447\u0435\u043c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e <code>Cat<\/code> \u0443\u0436\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 <code>Animal<\/code>, \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 <code>Komaru<\/code>, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>type Parent = Self<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>Parent<\/code>, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0443\u0431\u0440\u0430\u043b\u0438 <code>Cat<\/code> \u0443 <code>Komaru<\/code>, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u044b \u0435\u0435 \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b!<\/p>\n<\/li>\n<\/ol>\n<h2>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u0435\u0440\u0445\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0436\u0430\u0432\u043e\u043c, \u043d\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u0443\u043d\u0434\u044b, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c:<\/p>\n<pre><code class=\"rust\">trait Animal&lt;Parent: Animal&lt;Parent>> {     fn say(text: &amp;'static str) {         Parent::say(text);     } }   struct Cat;  impl Animal&lt;Self> for Cat {     fn say(text: &amp;'static str) {         println!(\"Meow: {text}\");     } }   struct Dog;  impl Animal&lt;Self> for Dog {     fn say(text: &amp;'static str) {         println!(\"Woof: {text}\");     } }   struct Kokoa;  impl Animal&lt;Cat> for Kokoa {} impl Animal&lt;Dog> for Kokoa {}   fn cat_sayer&lt;A>(text: &amp;'static str)      where A: Animal&lt;Cat> {         A::say(text); }  fn dog_sayer&lt;A>(text: &amp;'static str)      where A: Animal&lt;Dog> {         A::say(text); }   fn main() {     cat_sayer::&lt;Kokoa>(\"hello\");     dog_sayer::&lt;Kokoa>(\"bonjur\");      &lt;Kokoa as Animal&lt;Cat>>         ::say(\"\u0422\u0430\u043a\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0441\u043e\u043b\u044c\u044e!\"); }<\/code><\/pre>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0441 \u043e\u0434\u043d\u0438\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c, \u0432\u043c\u0435\u0441\u0442\u043e <code>type Parent<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0443\u043d\u0434, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u043c\u0443 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u0431\u044b\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438<code>Cat<\/code> \u0438 <code>Dog<\/code>. \u0423\u0432\u044b, \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0430\u0443\u043d\u0434\u043e\u0432 \u0443\u0436\u0435 \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f:<\/p>\n<pre><code class=\"rust\">trait BaseAnimal&lt;Parent: BaseAnimal&lt;Animal>> {     fn parent(&amp;self) -> &amp;Parent;      fn say(&amp;self, text: &amp;'static str) {         self.parent().say(text);     } }   struct Animal {     prefix: &amp;'static str, }  impl Animal {     fn new(prefix: &amp;'static str) -> Self {         Self { prefix }     } }  impl BaseAnimal&lt;Self> for Animal {     fn parent(&amp;self) -> &amp;Self {         &amp;self     }      fn say(&amp;self, text: &amp;'static str) {         println!(\"{}: {text}\", self.prefix);     } }   struct Cat(Animal);  impl Default for Cat {     fn default() -> Self {         Self(Animal::new(\"Meow\"))     } }  impl BaseAnimal&lt;Animal> for Cat {     fn parent(&amp;self) -> &amp;Animal {         &amp;self.0     } }   struct Dog(Animal);  impl Default for Dog {     fn default() -> Self {         Self(Animal::new(\"Woof\"))     } }  impl BaseAnimal&lt;Animal> for Dog {     fn parent(&amp;self) -> &amp;Animal {         &amp;self.0     } }   struct Komaru(Cat, Dog);  impl Default for Komaru {     fn default() -> Self {         Self(Cat::default(), Dog::default())     } }  impl BaseAnimal&lt;Cat> for Komaru {     fn parent(&amp;self) -> &amp;Cat {         &amp;self.0     } }  impl BaseAnimal&lt;Dog> for Komaru {     fn parent(&amp;self) -> &amp;Dog {         &amp;self.1     } }   fn unsized_cat_sayer&lt;A>()     where A: Default + BaseAnimal&lt;Cat> {         A::default().say(\"hello\"); }  fn sized_cat_sayer(animal: &amp;impl BaseAnimal&lt;Cat>) {     animal.say(\"hello\"); }   fn main() {     let komaru = Komaru::default();      unsized_cat_sayer::&lt;Komaru>();     sized_cat_sayer(&amp;komaru);      &lt;dyn BaseAnimal&lt;Cat>>         ::say(&amp;komaru, \"\u0427\u0442\u043e \u044f \u0442\u0430\u043a\u043e\u0435...\"); } <\/code><\/pre>\n<p>\u041f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0439, \u043a\u0440\u043e\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0443\u043d\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 <code>type Parent<\/code>. \u0412\u0430\u0436\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u0430. \u041f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-348710","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348710","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=348710"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348710\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}