{"id":363682,"date":"2024-05-21T02:01:21","date_gmt":"2024-05-21T02:01:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=363682"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=363682","title":{"rendered":"<span>\u0415\u0441\u0442\u044c \u043b\u0438 Undefined Behavior \u0432 Rust?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 Rust-\u043e\u043c, \u0430 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c Undefined Behavior (UB), \u0442\u043e \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e \u0442\u0430\u043a. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442 \u044f\u0437\u044b\u043a Rust \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: <strong>safe<\/strong> \u0438 <strong>unsafe<\/strong>. \u042f \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u043b \u043d\u0430 4 \u0447\u0430\u0441\u0442\u0438: safe, unsafe, <strong>const<\/strong> \u0438 <strong>async<\/strong>. \u041d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 safe \u0438 unsafe. <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c UB \u0432 Rust-\u0435 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043d\u0430\u0439\u0442\u0438 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0439 unsafe, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>get_unchecked<\/code> \u0443 <code>Vec<\/code>. \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0410 \u0435\u0441\u0442\u044c \u043b\u0438 UB \u0432 <strong>safe<\/strong>-\u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430? <strong>\u0415\u0441\u0442\u044c<\/strong>. \u041e\u043d \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430 (\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b) \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0438\u0432\u0435\u0442 \u0441 2015 \u0433\u043e\u0434\u0430. <\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"rust\">fn helper&lt;'a, 'b, T>(_: &amp;'a &amp;'b (), v: &amp;'b T) -> &amp;'a T { v }  pub fn make_static&lt;'a, T>(input: &amp;'a T) -> &amp;'static T {     let f: fn(_, &amp;'a T) -> &amp;'static T = helper;     f(&amp;&amp;(), input) }  fn main() {     let memory = make_static(&amp;vec![0; 1&lt;&lt;20]);     println!(\"{:?}\", memory); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0438 \u0440\u0435\u043b\u0438\u0437\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0432 \u0442\u043e\u043c \u0438 \u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 <strong>Segmentation fault<\/strong>.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435: \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0436\u0438\u0432\u0435\u0442 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>make_static<\/code> \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><strong>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440: \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0430\u044f \u0434\u043b\u044f Rust-\u0430.<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 MIR-\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0411\u0443\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c MIR-\u0430 \u0432 \u0434\u0435\u0431\u0430\u0433 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435:<\/p>\n<pre><code>..  let _1: &amp;std::vec::Vec&lt;i32>; let _2: &amp;std::vec::Vec&lt;i32>; let _3: std::vec::Vec&lt;i32>;  ..  bb2: {     _2 = &amp;_3;     _1 = make_static::&lt;Vec&lt;i32>>(_2) -> [return: bb3, unwind: bb8]; }  bb3: {     drop(_3) -> [return: bb4, unwind continue]; }  bb4: {     _15 = const _;     _9 = _15 as &amp;[&amp;str] (PointerCoercion(Unsize));     _14 = &amp;_1;     _13 = core::fmt::rt::Argument::&lt;'_>::new_debug::&lt;&amp;Vec&lt;i32>>(_14) -> [return: bb5, unwind continue]; }  bb5: {     _12 = [move _13];     _11 = &amp;_12;     _10 = _11 as &amp;[core::fmt::rt::Argument&lt;'_>] (PointerCoercion(Unsize));     _8 = Arguments::&lt;'_>::new_v1(move _9, move _10) -> [return: bb6, unwind continue]; }  bb6: {     _7 = _print(move _8) -> [return: bb7, unwind continue]; }<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p><code>_1 (memory)<\/code> &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>println!<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>_2<\/code> &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>make_static<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>_3<\/code> &#8212; \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 <code>bb2<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0430\u043c \u0432\u044b\u0437\u043e\u0432 <code>make_static<\/code>. \u0412 \u0431\u043b\u043e\u043a\u0435 <code>bb3<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0441\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434 \u043c\u0430\u0441\u0441\u0438\u0432. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 <code>stdout<\/code>.<\/p>\n<p>\u0418\u0442\u043e\u0433 &#8212; \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/div>\n<\/details>\n<h2>\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <strong>lifetimes<\/strong>. \u0412 Rust \u0442\u0438\u043f <code>&amp;'a T<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0438\u043f <code>T<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code>. \u041c\u0435\u0436\u0434\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0430\u043c\u0438 \u0436\u0438\u0437\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432 (<em>Subtyping<\/em>) \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (<em>Variance<\/em>). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>'a: 'b<\/code> (\u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u0430\u043a &#171;&#8216;a \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0435\u0442 &#8216;b&#187;), \u0435\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'b<\/code>. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 <code>&amp;'a &amp;'b T<\/code> \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 <code>'b: 'a<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0435\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'static<\/code>, \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e <code>'static: 'a<\/code> \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code>. \u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>\u041a\u043e\u043d\u0442\u0440\u0430\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438, \u0447\u0435\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>helper<\/code> \u0432 \u0442\u0438\u043f\u0435 <code>fn(_, &amp;'a T) -> &amp;'static T<\/code>.<\/p>\n<blockquote>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b \u0440\u0435\u0448\u0435\u043d. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0442\u0430\u043c \u0431\u044b\u043b \u0442\u0438\u043f <code>fn(&amp;'static &amp;'a (), &amp;'a T) -> &amp;'static T<\/code> , \u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 placeholder (\u043d\u0438\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u0442) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 type checker-\u0430.<\/p>\n<\/blockquote>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 2024 \u0433\u043e\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u0435\u0434\u0443\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u044b. \u0411\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043c\u0435\u043d\u0430 trait solver-\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 <code>for&lt;'a, 'b> fn(&amp;'a &amp;'b (), &amp;'b T) -> &amp;'a T<\/code>\u0434\u043e <code>for&lt;'a, 'b> where&lt;'b:'a, T:'b> fn(&amp;'a &amp;'b (), &amp;'b T) -> &amp;'a T<\/code>;<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043b\u043e\u0432\u0443\u0448\u043a\u0443, \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0434\u043b\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u044f\u0432\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 <code>where<\/code>-\u0431\u043b\u043e\u043a\u0435 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d \u0436\u0438\u0437\u043d\u0438.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/meithecatte\/fake-static\/tree\/master\" rel=\"noopener noreferrer nofollow\">fake-static \u043a\u0440\u0435\u0439\u0442<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/issues\/25860\" rel=\"noopener noreferrer nofollow\">Implied bounds on nested references + variance = soundness hole<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/counterexamples.org\/nearly-universal.html?highlight=Rust\" rel=\"noopener noreferrer nofollow\">Counterexamples in Type Systems<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/issues\/107374\" rel=\"noopener noreferrer nofollow\">Tracking Issue for\u00a0-Znext-solver\u00a0<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/blog.rust-lang.org\/2023\/01\/20\/types-announcement.html\" rel=\"noopener noreferrer nofollow\">Officially announcing the types team<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/nikomatsakis\/rfcs\/blob\/sionara-contravariance\/text\/0000-wf-and-variance.md\" rel=\"noopener noreferrer nofollow\">RFC Well formed and variance<\/a><\/p>\n<\/li>\n<\/ul>\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\/782412\/\"> https:\/\/habr.com\/ru\/articles\/782412\/<\/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<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 Rust-\u043e\u043c, \u0430 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c Undefined Behavior (UB), \u0442\u043e \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u044d\u0442\u043e \u0442\u0430\u043a. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442 \u044f\u0437\u044b\u043a Rust \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: <strong>safe<\/strong> \u0438 <strong>unsafe<\/strong>. \u042f \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u043b \u043d\u0430 4 \u0447\u0430\u0441\u0442\u0438: safe, unsafe, <strong>const<\/strong> \u0438 <strong>async<\/strong>. \u041d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 safe \u0438 unsafe. <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c UB \u0432 Rust-\u0435 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043d\u0430\u0439\u0442\u0438 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0439 unsafe, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>get_unchecked<\/code> \u0443 <code>Vec<\/code>. \u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0410 \u0435\u0441\u0442\u044c \u043b\u0438 UB \u0432 <strong>safe<\/strong>-\u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u044f\u0437\u044b\u043a\u0430? <strong>\u0415\u0441\u0442\u044c<\/strong>. \u041e\u043d \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430 (\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b) \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0438\u0432\u0435\u0442 \u0441 2015 \u0433\u043e\u0434\u0430. <\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"rust\">fn helper&lt;'a, 'b, T>(_: &amp;'a &amp;'b (), v: &amp;'b T) -> &amp;'a T { v }  pub fn make_static&lt;'a, T>(input: &amp;'a T) -> &amp;'static T {     let f: fn(_, &amp;'a T) -> &amp;'static T = helper;     f(&amp;&amp;(), input) }  fn main() {     let memory = make_static(&amp;vec![0; 1&lt;&lt;20]);     println!(\"{:?}\", memory); }<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u0438 \u0440\u0435\u043b\u0438\u0437\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u043e \u0432 \u0442\u043e\u043c \u0438 \u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 <strong>Segmentation fault<\/strong>.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435: \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0436\u0438\u0432\u0435\u0442 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>make_static<\/code> \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><strong>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440: \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u0434\u0435\u0442 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0430\u044f \u0434\u043b\u044f Rust-\u0430.<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 MIR-\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0411\u0443\u0434\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c MIR-\u0430 \u0432 \u0434\u0435\u0431\u0430\u0433 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435:<\/p>\n<pre><code>..  let _1: &amp;std::vec::Vec&lt;i32>; let _2: &amp;std::vec::Vec&lt;i32>; let _3: std::vec::Vec&lt;i32>;  ..  bb2: {     _2 = &amp;_3;     _1 = make_static::&lt;Vec&lt;i32>>(_2) -> [return: bb3, unwind: bb8]; }  bb3: {     drop(_3) -> [return: bb4, unwind continue]; }  bb4: {     _15 = const _;     _9 = _15 as &amp;[&amp;str] (PointerCoercion(Unsize));     _14 = &amp;_1;     _13 = core::fmt::rt::Argument::&lt;'_>::new_debug::&lt;&amp;Vec&lt;i32>>(_14) -> [return: bb5, unwind continue]; }  bb5: {     _12 = [move _13];     _11 = &amp;_12;     _10 = _11 as &amp;[core::fmt::rt::Argument&lt;'_>] (PointerCoercion(Unsize));     _8 = Arguments::&lt;'_>::new_v1(move _9, move _10) -> [return: bb6, unwind continue]; }  bb6: {     _7 = _print(move _8) -> [return: bb7, unwind continue]; }<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p><code>_1 (memory)<\/code> &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 <code>println!<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>_2<\/code> &#8212; \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>make_static<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>_3<\/code> &#8212; \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 <code>bb2<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0430\u043c \u0432\u044b\u0437\u043e\u0432 <code>make_static<\/code>. \u0412 \u0431\u043b\u043e\u043a\u0435 <code>bb3<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0441\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434 \u043c\u0430\u0441\u0441\u0438\u0432. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432 <code>stdout<\/code>.<\/p>\n<p>\u0418\u0442\u043e\u0433 &#8212; \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/div>\n<\/details>\n<h2>\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <strong>lifetimes<\/strong>. \u0412 Rust \u0442\u0438\u043f <code>&amp;'a T<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0438\u043f <code>T<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code>. \u041c\u0435\u0436\u0434\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0430\u043c\u0438 \u0436\u0438\u0437\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043f\u043e\u0434\u0442\u0438\u043f\u043e\u0432 (<em>Subtyping<\/em>) \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (<em>Variance<\/em>). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>'a: 'b<\/code> (\u043f\u0440\u043e\u0438\u0437\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u0430\u043a &#171;&#8216;a \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0435\u0442 &#8216;b&#187;), \u0435\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'b<\/code>. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 <code>&amp;'a &amp;'b T<\/code> \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 <code>'b: 'a<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0435\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 <code>'static<\/code>, \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e <code>'static: 'a<\/code> \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 <code>'a<\/code>. \u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>\u041a\u043e\u043d\u0442\u0440\u0430\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438, \u0447\u0435\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>helper<\/code> \u0432 \u0442\u0438\u043f\u0435 <code>fn(_, &amp;'a T) -> &amp;'static T<\/code>.<\/p>\n<blockquote>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b \u0440\u0435\u0448\u0435\u043d. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0442\u0430\u043c \u0431\u044b\u043b \u0442\u0438\u043f <code>fn(&amp;'static &amp;'a (), &amp;'a T) -> &amp;'static T<\/code> , \u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 placeholder (\u043d\u0438\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u0442) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 type checker-\u0430.<\/p>\n<\/blockquote>\n<h2>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 2024 \u0433\u043e\u0434\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u0435\u0434\u0443\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u044b. \u0411\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043c\u0435\u043d\u0430 trait solver-\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 <code>for&lt;'a, 'b> fn(&amp;'a &amp;'b (), &amp;'b T) -> &amp;'a T<\/code>\u0434\u043e <code>for&lt;'a, 'b> where&lt;'b:'a, T:'b> fn(&amp;'a &amp;'b (), &amp;'b T) -> &amp;'a T<\/code>;<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u0438\u043c \u043d\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043b\u043e\u0432\u0443\u0448\u043a\u0443, \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0434\u043b\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u044f\u0432\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 <code>where<\/code>-\u0431\u043b\u043e\u043a\u0435 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d \u0436\u0438\u0437\u043d\u0438.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/meithecatte\/fake-static\/tree\/master\" rel=\"noopener noreferrer nofollow\">fake-static \u043a\u0440\u0435\u0439\u0442<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/issues\/25860\" rel=\"noopener noreferrer nofollow\">Implied bounds on nested references + variance = soundness hole<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/counterexamples.org\/nearly-universal.html?highlight=Rust\" rel=\"noopener noreferrer nofollow\">Counterexamples in Type Systems<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rust-lang\/rust\/issues\/107374\" rel=\"noopener noreferrer nofollow\">Tracking Issue for\u00a0-Znext-solver\u00a0<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/blog.rust-lang.org\/2023\/01\/20\/types-announcement.html\" rel=\"noopener noreferrer nofollow\">Officially announcing the types team<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/nikomatsakis\/rfcs\/blob\/sionara-contravariance\/text\/0000-wf-and-variance.md\" rel=\"noopener noreferrer nofollow\">RFC Well formed and variance<\/a><\/p>\n<\/li>\n<\/ul>\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\/782412\/\"> https:\/\/habr.com\/ru\/articles\/782412\/<\/a><br \/><\/br><\/br><\/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-363682","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363682","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=363682"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363682\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=363682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=363682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=363682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}