{"id":340878,"date":"2022-11-07T15:00:27","date_gmt":"2022-11-07T15:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340878"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340878","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 Rust<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/697772\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-l\/id\/yb\/-lidyb2-_fbfemz7idl8wmlzaqs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-l\/id\/yb\/-lidyb2-_fbfemz7idl8wmlzaqs.png\"\/><\/a><\/p>\n<p>  \u042f \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0438\u0437\u0443\u0447\u0430\u0442\u044c Rust. \u041a\u0440\u043e\u043c\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u0434\u043b\u044f \u0437\u043d\u0430\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0434\u0438\u043e\u043c\u044b \u0438 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043d\u0430\u0445\u043e\u0436\u0443\u0441\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 Rust.<\/p>\n<h2><font color=\"#3AC1EF\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/font><\/h2>\n<p>  \u0412 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u043b\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JVM \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u0412\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">class Car(private val engine: Engine) {      fun start() {         engine.start()     } }  interface Engine {     fun start() }  class CarEngine(): Engine {     override fun start() = ... }  class TestEngine(): Engine {     override fun start() = ... }<\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">val car = Car(CarEngine())<\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">val dummy = Car(TestEngine())<\/code><\/pre>\n<p>  \u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<blockquote><p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>#[test]<\/code> \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 <code>fn<\/code>. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>cargo test<\/code> Rust \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0449\u0438\u0439, \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c \u043b\u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/p>\n<p>   \u2014 <a href=\"https:\/\/doc.rust-lang.org\/book\/ch11-01-writing-tests.html#the-anatomy-of-a-test-function\">The Anatomy of a Test Function<\/a><\/p><\/blockquote>\n<p>  \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041e\u043d\u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>cargo test<\/code>:<\/p>\n<pre><code class=\"rust\">fn main() {     println!(\"{}\", hello()); }  fn hello() -> &amp;'static str {     return \"Hello world\"; }  #[test] fn test_hello() {     assert_eq!(hello(), \"Hello world\"); }<\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 <code>cargo run<\/code> \u0434\u0430\u0451\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"plaintext\">Hello world<\/code><\/pre>\n<p>  \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 <code>cargo run<\/code> \u0434\u0430\u0451\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"plaintext\">running 1 test test test_hello ... ok  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s   running 0 tests  test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u0448\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0442\u043e\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c.<\/p>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441 <code>test<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e.<\/p>\n<h2><font color=\"#3AC1EF\">\u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0441 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c cfg<\/font><\/h2>\n<p>  Rust \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u00ab\u044e\u043d\u0438\u0442\u00bb-\u0442\u0435\u0441\u0442\u044b \u0438 \u00ab\u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435\u00bb \u0442\u0435\u0441\u0442\u044b. \u042f \u043f\u0438\u0448\u0443 \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u0431\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u043e\u043b\u043a\u0443. \u0412\u043e\u0442 \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f:<\/p>\n<ul>\n<li>\u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435, \u0447\u0442\u043e \u0438 main. \u041c\u043e\u0436\u043d\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c <code>#[test]<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>cargo test<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435.<\/li>\n<li>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u043a\u043e\u0434\u0443. \u041a\u043e\u0434 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <code>#[cfg(test)]<\/code>.<\/li>\n<\/ul>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <code>cfg<\/code>:<\/p>\n<blockquote><p>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u044b \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u044f \u0444\u043b\u0430\u0433\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443 <code>#[cfg]<\/code> \u044d\u0442\u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u043b\u0435\u0432\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0444\u043b\u0430\u0433\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044e \u043e\u0431\u044a\u0451\u043c\u0430 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>   \u2014 <a href=\"https:\/\/doc.rust-lang.org\/std\/macro.cfg.html\">Macro std::cfg<\/a><\/p><\/blockquote>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441 <code>cfg<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438:<\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f<\/th>\n<th>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/th>\n<th>\u041f\u0440\u0438\u043c\u0435\u0440<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>target_arch<\/code><\/td>\n<td>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0426\u041f<\/td>\n<td>\n<ul>\n<li><code>\"x86\"<\/code><\/li>\n<li><code>\"arm\"<\/code><\/li>\n<li><code>\"aarch64\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_feature<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td>\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/td>\n<td>\n<ul>\n<li><code>\"rdrand\"<\/code><\/li>\n<li><code>\"sse\"<\/code><\/li>\n<li><code>\"se2\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_os<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b<\/td>\n<td>\n<ul>\n<li><code>\"windows\"<\/code><\/li>\n<li><code>\"macos\"<\/code><\/li>\n<li><code>\"linux\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_family<\/code><\/td>\n<td>\u041e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0438\u043b\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440<\/td>\n<td>\n<ul>\n<li><code>\"windows\"<\/code><\/li>\n<li><code>\"unix\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_env<\/code><\/td>\n<td>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c <code><code>ABI \u0438\u043b\u0438 <\/code>libc<\/code><\/td>\n<td>\n<ul>\n<li><code>\"\"<\/code><\/li>\n<li><code>\"gnu\"<\/code><\/li>\n<li><code>\"musl\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_endian<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td colspan=\"2\"><code>\"big\"<\/code> \u0438\u043b\u0438 <code>\"little\"<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>target_pointer_width<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td>\u0428\u0438\u0440\u0438\u043d\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0432 \u0431\u0438\u0442\u0430\u0445<\/td>\n<td>\n<ul>\n<li><code>\"32\"<\/code><\/li>\n<li><code>\"64\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>target_vendor<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b<\/td>\n<td>\n<ul>\n<li><code>\"apple\"<\/code><\/li>\n<li><code>\"pc\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><code>test<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td colspan=\"2\">\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043e\u0431\u0432\u044f\u0437\u043a\u0438<\/td>\n<\/tr>\n<tr>\n<td><code>proc_macro<\/code><\/p>\n<p>\u00a0<\/p>\n<\/td>\n<td colspan=\"2\">\u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0439 crate \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 <code>proc_macro<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>panic<\/code><\/td>\n<td>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043f\u0430\u043d\u0438\u043a\u0438<\/td>\n<td>\n<ul>\n<li><code>\"abort\"<\/code><\/li>\n<li><code>\"unwind\"<\/code><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0444\u043b\u0430\u0433 <code>test<\/code>. \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c <code>#[cfg(test)]<\/code>:<\/p>\n<pre><code class=\"rust\">#[cfg(test)] fn test_something() {     \/\/ Whatever }<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 <code>test<\/code>:<\/p>\n<pre><code class=\"rust\">fn hello() -> &amp;'static str {     return \"Hello world\"; }  #[cfg(test)] fn hello() -> &amp;'static str {     return \"Hello test\"; }<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f <code>cargo run<\/code>, \u043d\u043e \u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f <code>cargo test<\/code>. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0438 Rust \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439.<\/p>\n<pre><code class=\"plaintext\">error[E0428]: the name `hello` is defined multiple times   --> src\/lib.rs:10:1    | 5  | fn hello() -> &amp;'static str {    | -------------------------- previous definition of the value `hello` here ... 10 | fn hello() -> &amp;'static str {    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `hello` redefined here    | \u00a0 \u00a0= note: `hello` must be defined only once in the value namespace of this module<\/code><\/pre>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043c\u0430\u043a\u0440\u043e\u0441 <code>cfg<\/code> \u0438\u043c\u0435\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u0443 \u043b\u043e\u0433\u0438\u043a\u0443. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>test<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"rust\">fn main() {     println!(\"{}\", hello()); }  #[cfg(not(test))] fn hello() -> &amp;'static str {     return \"Hello world\"; }  #[cfg(test)] fn hello() -> &amp;'static str {     return \"Hello test\"; }  #[test] fn test_hello() {     assert_eq!(hello(), \"Hello test\"); }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>cargo run<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e <code>Hello world<\/code>,<\/li>\n<li><code>cargo test<\/code> <em>\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/em>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0442\u0435\u0441\u0442.<\/li>\n<\/ul>\n<p>  \u0425\u043e\u0442\u044c \u044d\u0442\u043e \u0438 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u043c\u0435\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043e\u043d \u0434\u0432\u043e\u0438\u0447\u0435\u043d \u2014 \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u0438\u043b\u0438 \u043d\u0435\u0442,<\/li>\n<li>\u043d\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u0442\u0441\u044f: \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0421\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/font><\/h2>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0432 JVM:<\/p>\n<ul>\n<li>\u043f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u043e\u043d\u0435 \u043a\u043e\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Postgres,<\/li>\n<li>\u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 SQLite,<\/li>\n<li>\u0434\u043b\u044f \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044e.<\/li>\n<\/ul>\n<p>  \u0412\u043e\u0442 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"rust\">fn main() {     \/\/ Get a database implementation                          \/\/ 1     db.do_stuff(); }  trait Database {     fn doStuff(self: Self); }  struct MockDatabase {} struct SqlitDatabase {} struct PostgreSqlDatabase {}  impl Database for MockDatabase {     fn doStuff(self: Self) {         println!(\"Do mock stuff\");     } }  impl Database for SqlitDatabase {     fn doStuff(self: Self) {         println!(\"Do stuff with SQLite\");     } }   impl Database for PostgreSqlDatabase {     fn doStuff(self: Self) {         println!(\"Do stuff with PostgreSQL\");     } }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430?<\/p>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0430 <code>cfg[test]<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0444\u043b\u0430\u0433. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<h2><font color=\"#3AC1EF\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Cargo<\/font><\/h2>\n<p>  \u0412 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f \u0437\u0430\u0434\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u0432 Slack-\u043a\u0430\u043d\u0430\u043b\u0435 Rust. <a href=\"http:\/\/housedillon.com\/\" rel=\"noopener noreferrer\">\u0423\u0438\u043b\u044c\u044f\u043c \u0414\u0438\u043b\u043b\u043e\u043d<\/a> \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043c\u043d\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 (feature) Cargo.<\/p>\n<blockquote><p>\u0423 Cargo \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041f\u0430\u043a\u0435\u0442 \u0437\u0430\u0434\u0430\u0451\u0442 \u043d\u0430\u0431\u043e\u0440 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>[features]<\/code> \u0444\u0430\u0439\u043b\u0430 <code>Cargo.toml<\/code>, \u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 <code>--features<\/code>. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 <code>Cargo.toml<\/code>.<\/p>\n<p>   \u2014 <a href=\"https:\/\/doc.rust-lang.org\/cargo\/reference\/features.html\" rel=\"noopener noreferrer\">Features<\/a><\/p><\/blockquote>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0417\u0430\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/font><\/h3>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041e\u043d\u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>Cargo.toml<\/code>:<\/p>\n<pre><code class=\"xml\">[features] unit = [] it = [] prod = []<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0432 \u043a\u043e\u0434\u0435<\/font><\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c, \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 <code>cfg<\/code>:<\/p>\n<pre><code class=\"rust\">fn main() {     #[cfg(feature = \"unit\")]                   \/\/ 1     let db = MockDatabase {};     #[cfg(feature = \"it\")]                     \/\/ 2     let db = SqlitDatabase {};     #[cfg(feature = \"prod\")]                   \/\/ 3     let db = PostgreSqlDatabase {};     db.do_stuff(); }  trait Database {     fn do_stuff(self: Self); }  #[cfg(feature = \"unit\")]                       \/\/ 1 struct MockDatabase {}  #[cfg(feature = \"unit\")]                       \/\/ 1 impl Database for MockDatabase {     fn do_stuff(self: Self) {         println!(\"Do mock stuff\");     } }  \/\/ \u0423\u0440\u0435\u0437\u0430\u043d\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ 2-3<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>unit<\/code>.<\/li>\n<li>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>it<\/code>.<\/li>\n<li>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>prod<\/code>.<\/li>\n<\/ol>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0410\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/font><\/h3>\n<p>  \u0414\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043b\u0430\u0433 <code>-F<\/code>.<\/p>\n<pre><code class=\"plaintext\">cargo run -F unit<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Do mock stuff<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/font><\/h3>\n<p>  \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abproduction\u00bb \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  \u042f \u0443\u0436\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439: \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u043b\u0435\u0433\u0430 \u0432 \u043e\u0442\u043f\u0443\u0441\u043a\u0435, \u0430 \u0442\u0435\u0431\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443, \u0442\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u043c\u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  Rust \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u00ab\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435\u00bb \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0418\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043e\u043d\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>Cargo.toml<\/code>.<\/p>\n<pre><code class=\"plaintext\">[features] default = [\"prod\"]                             # 1 unit = [] it = [] prod = []<\/code><\/pre>\n<p>  \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>prod<\/code> \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u043a\u0430\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043d\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u044f\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>prod<\/code>:<\/p>\n<pre><code class=\"plaintext\">cargo run<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Do stuff with PostgreSQL<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u258d \u0418\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/font><\/h3>\n<p>  \u0412\u0441\u0435 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c\u0438: \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0438\u0445. \u0414\u043b\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0430\u0433:<\/p>\n<pre><code class=\"plaintext\">cargo run --no-default-features -F unit<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Do mock stuff<\/code><\/pre>\n<p>  \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432:<\/p>\n<blockquote><p>\u0412 \u0440\u0435\u0434\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043d\u043e \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u043c\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u042d\u0442\u043e\u0433\u043e \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 \u0432 \u0433\u0440\u0430\u0444 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.<\/p>\n<p>   \u2014 <a href=\"https:\/\/doc.rust-lang.org\/cargo\/reference\/features.html#mutually-exclusive-features\">Mutually exclusive features<\/a><\/p><\/blockquote>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"rust\">#[cfg(all(feature = \"unit\", feature = \"it\"))] compile_error!(\"feature \\\"unit\\\" and feature \\\"it\\\" cannot be enabled at the same time\"); #[cfg(all(feature = \"unit\", feature = \"prod\"))] compile_error!(\"feature \\\"unit\\\" and feature \\\"prod\\\" cannot be enabled at the same time\"); #[cfg(all(feature = \"it\", feature = \"prod\"))] compile_error!(\"feature \\\"it\\\" and feature \\\"prod\\\" cannot be enabled at the same time\");<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>unit<\/code>, \u043f\u043e\u043a\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>prod<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:<\/p>\n<pre><code class=\"plaintext\">cargo run -F unit<\/code><\/pre>\n<p>  \u0422\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"plaintext\">error: feature \"unit\" and feature \"prod\" cannot be enabled at the same time  --> src\/main.rs:4:1   | 4 | compile_error!(\"feature \\\"unit\\\" and feature \\\"prod\\\" cannot be enabled at the same time\"); \u00a0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443<\/font><\/h2>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0437\u0430\u043f\u0443\u0442\u044b\u0432\u0430\u0435\u0442. \u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>main<\/code>, \u0430 \u0441\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u043e\u0432\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b \u043a\u0430\u043a \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0430\u0437\u0435.<\/p>\n<pre><code class=\"rust\">#[cfg(feature = \"prod\")]                            \/\/ 1 fn main() {     let db = PostgreSqlDatabase {};     println!(\"{}\", db.do_stuff()); }  trait Database {     fn do_stuff(self: Self) -> &amp;'static str;        \/\/ 2 }  #[cfg(feature = \"unit\")] struct MockDatabase {} #[cfg(feature = \"prod\")] struct PostgreSqlDatabase {}  #[cfg(feature = \"unit\")] impl Database for MockDatabase {     fn do_stuff(self: Self) -> &amp;'static str {         \"Do mock stuff\"     } }  #[cfg(feature = \"prod\")] impl Database for PostgreSqlDatabase {     fn do_stuff(self: Self) -> &amp;'static str {         \"Do stuff with PostgreSQL\"     } }  #[test] #[cfg(feature = \"unit\")] fn test_unit() {     let db = MockDatabase {};     assert_eq!(db.do_stuff(), \"Do mock stuff\");     \/\/ 3 }  \/\/ \u043e\u043f\u0443\u0449\u0435\u043d\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>PostgreSqlDatabase<\/code> \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430, \u043a\u043e\u0433\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043b\u044e\u0431\u043e\u0435 \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/li>\n<li>\u0418\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/li>\n<li>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c!<\/li>\n<\/ol>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"plaintext\">cargo test --no-default-features -F unit            #1 cargo test --no-default-features -F it              #2 cargo run \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 #3<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442.<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442.<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/li>\n<\/ol>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0432\u044b\u0437\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>test<\/code> \u0434\u0432\u043e\u0438\u0447\u043d\u0430: \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>test<\/code>, \u0438\u043b\u0438 \u043d\u0435\u0442. \u042d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Rust. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e (feature) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u0434 \u043c\u0435\u0442\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e, \u0442\u043e \u044f \u043d\u0435 \u0437\u043d\u0430\u044e, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Rust \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u0430\u043a \u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e, \u044d\u0442\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0438 \u043f\u043e\u043c\u043e\u0433\u043b\u043e \u043c\u043d\u0435 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 Rust.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/ajavageek\/rust-test-suites\">GitHub<\/a>.<\/p>\n<p>  \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f:  <\/p>\n<ul>\n<li><a href=\"https:\/\/doc.rust-lang.org\/book\/ch11-00-testing.html\">Testing in Rust<\/a><\/li>\n<li><a href=\"https:\/\/doc.rust-lang.org\/rust-by-example\/testing.html\">Rust by example: testing<\/a><\/li>\n<li><a href=\"https:\/\/doc.rust-lang.org\/reference\/conditional-compilation.html\">Conditional compilation<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p><b><font color=\"#3AC1EF\"><a href=\"https:\/\/inlnk.ru\/dn6PzK\">Telegram-\u043a\u0430\u043d\u0430\u043b \u0441 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044f\u043c\u0438<\/a> \u0438 <a href=\"https:\/\/inlnk.ru\/ZZMz0Y\">\u0443\u044e\u0442\u043d\u044b\u0439 \u0447\u0430\u0442<\/a><\/font><\/b><\/p><\/blockquote>\n<p><a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=perevod&amp;utm_content=testirovanie_rust\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\" data-src=\"https:\/\/habrastorage.org\/webt\/sz\/7j\/pf\/sz7jpfj8i1pa6ocj-eia09dev4q.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/697772\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/697772\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/697772\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-l\/id\/yb\/-lidyb2-_fbfemz7idl8wmlzaqs.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-l\/id\/yb\/-lidyb2-_fbfemz7idl8wmlzaqs.png\"\/><\/a><\/p>\n<p>  \u042f \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0438\u0437\u0443\u0447\u0430\u0442\u044c Rust. \u041a\u0440\u043e\u043c\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u0434\u043b\u044f \u0437\u043d\u0430\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0434\u0438\u043e\u043c\u044b \u0438 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043d\u0430\u0445\u043e\u0436\u0443\u0441\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 Rust.<\/p>\n<h2><font color=\"#3AC1EF\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/font><\/h2>\n<p>  \u0412 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u043b\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 JVM \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u0412\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"kotlin\">class Car(private val engine: Engine) {      fun start() {         engine.start()     } }  interface Engine {     fun start() }  class CarEngine(): Engine {     override fun start() = ... }  class TestEngine(): Engine {     override fun start() = ... }<\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">val car = Car(CarEngine())<\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"kotlin\">val dummy = Car(TestEngine())<\/code><\/pre>\n<p>  \u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c.  <\/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-340878","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340878","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=340878"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340878\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}