{"id":21,"date":"2022-01-24T21:14:00","date_gmt":"2022-01-24T20:14:00","guid":{"rendered":"https:\/\/noiseonthenet.space\/noise\/?p=21"},"modified":"2022-01-25T10:41:18","modified_gmt":"2022-01-25T09:41:18","slug":"crates-and-cargo","status":"publish","type":"post","link":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/","title":{"rendered":"Crates and cargo"},"content":{"rendered":"<div id=\"orgd28e6c3\" class=\"figure\">\n\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-61 aligncenter\" src=\"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?resize=300%2C200&#038;ssl=1\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?resize=300%2C200&amp;ssl=1 300w, https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?resize=1024%2C683&amp;ssl=1 1024w, https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?resize=768%2C512&amp;ssl=1 768w, https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?resize=1536%2C1024&amp;ssl=1 1536w, https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\n\n<\/div>\nPhoto by <a href=\"https:\/\/unsplash.com\/@kelli_mcclintock?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" data-bcup-haslogintext=\"no\">Kelli McClintock<\/a> on <a href=\"https:\/\/unsplash.com\/s\/photos\/box?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" data-bcup-haslogintext=\"no\">Unsplash<\/a>\n\nThis post is aimed at collecting some notes for crates usage, <code>cargo<\/code> is a fundamental element of this description being the main toolchain manager. It is more a roundup I needed to reconcile <code>cargo<\/code> file layout and default behavior with rust\n\nYou can find other references about modules, crates and packages in the 7th <a href=\"https:\/\/doc.rust-lang.org\/book\/ch07-00-managing-growing-projects-with-packages-crates-and-modules.html\" data-bcup-haslogintext=\"no\">chapter<\/a> of the Rust Book.\n\nThe code in this post is available <a href=\"https:\/\/github.com\/noiseOnTheNet\/cargo_and_crates\" data-bcup-haslogintext=\"no\">on GitHub<\/a> with MIT license.\n<div id=\"outline-container-org1545ecc\" class=\"outline-2\">\n<h2 id=\"org1545ecc\">a few things about cargo<\/h2>\n<div id=\"text-org1545ecc\" class=\"outline-text-2\"><\/div>\n<div id=\"outline-container-org20d9169\" class=\"outline-3\">\n<h3 id=\"org20d9169\">basic default file layout for cargo<\/h3>\n<div id=\"text-org20d9169\" class=\"outline-text-3\">\n\ncargo has a default layout: with the same toml you may expect\n<ul class=\"org-ul\">\n \t<li>a binary project as generated by<\/li>\n<\/ul>\n<pre id=\"nil\" class=\"example\">projectdir\/\n\u251c\u2500 Cargo.toml\n\u2514\u2500 src\/\n   \u2514\u2500 main.rs\n<\/pre>\n<ul class=\"org-ul\">\n \t<li>a library project<\/li>\n<\/ul>\n<pre id=\"nil\" class=\"example\">projectdir\/\n\u251c\u2500 Cargo.toml\n\u2514\u2500 src\/\n   \u2514\u2500 lib.rs\n<\/pre>\nin both case you get compilation with\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-bash\">cargo build\n<\/pre>\n<\/div>\nwhile in the binary case you can also run the code with\n<pre id=\"nil\" class=\"example\">cargo run\n<\/pre>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgaefe676\" class=\"outline-3\">\n<h3 id=\"orgaefe676\">compilation target basics<\/h3>\n<div id=\"text-orgaefe676\" class=\"outline-text-3\">\n\n<code>cargo<\/code> has some commands and options aimed to compile differently the code and possibly also choose specific output\n\nWhen compiling the code with commands <code>build<\/code> or <code>run<\/code> the default target is <code>dev<\/code> while production compilation requires the flag <code>cargo build --release<\/code> : this triggers also some optimizations.\n\n<\/div>\n<\/div>\n<div id=\"outline-container-org4b9ebfe\" class=\"outline-3\">\n<h3 id=\"org4b9ebfe\">library and tests<\/h3>\n<div id=\"text-org4b9ebfe\" class=\"outline-text-3\">\n\nlibrary example generated by <code>cargo new projectname --lib<\/code> contains some test example to start unit testing: looks like this is the suggested feature\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span class=\"linenr\">1: <\/span><span style=\"color: #23d7d7;\">#[cfg(test)]<\/span>\n<span class=\"linenr\">2: <\/span><span style=\"color: #ffad29; font-weight: bold;\">mod<\/span> <span style=\"color: #008b8b;\">tests<\/span> {\n<span class=\"linenr\">3: <\/span>    <span style=\"color: #23d7d7;\">#[test]<\/span>\n<span class=\"linenr\">4: <\/span>    <span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">it_works<\/span>() {\n<span class=\"linenr\">5: <\/span>        <span style=\"color: #23d7d7;\">assert_eq!<\/span>(2 + 2, 4);\n<span class=\"linenr\">6: <\/span>    }\n<span class=\"linenr\">7: <\/span>}\n<\/pre>\n<\/div>\n<ul class=\"org-ul\">\n \t<li>line 1 contains a macro that ensure the following entity to be compiled only if the \"test\" target is selected, which is what happens running <code>cargo test<\/code><\/li>\n \t<li>line 2 starts a module within this file, this will be compiled only according to the macro at line 1<\/li>\n \t<li>line 3 contains a macro which will add some boilerplate code used to execute the following function and collect its result when executing tests<\/li>\n \t<li>line 5 contains a macro checking the two arguments for equality and then raising an exception if the do not equals\n<ul class=\"org-ul\">\n \t<li>equality is defined by a specific trait<\/li>\n \t<li>if the exception is raised the test is failed<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-bash\">cargo test\n<\/pre>\n<\/div>\n<ul class=\"org-ul\">\n \t<li>this command also executes all the tests<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org54a1d14\" class=\"outline-2\">\n<h2 id=\"org54a1d14\">how rust groups code<\/h2>\n<div id=\"text-org54a1d14\" class=\"outline-text-2\"><\/div>\n<div id=\"outline-container-org0e1daaa\" class=\"outline-3\">\n<h3 id=\"org0e1daaa\">the code hierarchy<\/h3>\n<div id=\"text-org0e1daaa\" class=\"outline-text-3\">\n\nRust uses this hierarchical structure\n<pre id=\"nil\" class=\"example\">packages\n\u2514\u2500 crates\n   \u2514\u2500 modules\n      \u251c\u2500 functions\n      \u251c\u2500 structures and enums\n      \u2514\u2500 traits\n<\/pre>\npackages are the highest level: they can be external, built-in (e.g. <code>std<\/code>) or user created. Each project defined by a Cargo.toml is a package\n\nEach package can contain a hierarchy of crates, which means they have the same root and do not have circular dependencies\n\nEach crate can contain a hierarchy of modules with possibly different access permissions\n\nactual code is always in the modules\n\n<\/div>\n<\/div>\n<div id=\"outline-container-orga26a20f\" class=\"outline-3\">\n<h3 id=\"orga26a20f\">the crate and modules default<\/h3>\n<div id=\"text-orga26a20f\" class=\"outline-text-3\">\n\nwhen creating a library project with cargo the <code>lib.rs<\/code> file contains the code which will be attributed by default to the crate with the same name as the project\n\nall modules are defined by using the <code>mod<\/code> keyword followed by a block; modules definition can be nested\n\nModules act as namespace and as incapsulation protection. While modules on the same file are accessible, their inner objects should be marked as <code>pub<\/code> (short for public) to be accessible\n<div class=\"org-src-container\"><label class=\"org-src-name\"><em> Name: nested-module-example.<\/em><\/label>\n<pre id=\"nested-module-example\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">mod<\/span> <span style=\"color: #008b8b;\">mymodule<\/span> {\n    <span style=\"color: #ffad29; font-weight: bold;\">pub<\/span> <span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">myfunc<\/span>(){}\n    <span style=\"color: #ffad29; font-weight: bold;\">pub<\/span> <span style=\"color: #ffad29; font-weight: bold;\">mod<\/span> <span style=\"color: #008b8b;\">mysubmodule<\/span>{\n        <span style=\"color: #ffad29; font-weight: bold;\">pub<\/span> <span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">myotherfunc<\/span>(){}\n    }\n}\n<\/pre>\n<\/div>\naccessing modules from within the same file can be done via a path\n<div class=\"org-src-container\"><label class=\"org-src-name\"><em> Name: nested-module-basic-usage.<\/em><\/label>\n<pre id=\"nested-module-basic-usage\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">main<\/span>(){\n    <span style=\"color: #008b8b;\">mymodule<\/span>::myfunc();\n    <span style=\"color: #008b8b;\">mymodule<\/span>::<span style=\"color: #008b8b;\">mysubmodule<\/span>::myotherfunc();\n}\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org8833ca6\" class=\"outline-3\">\n<h3 id=\"org8833ca6\">use keyword and navigating the crate hierarchy<\/h3>\n<div id=\"text-org8833ca6\" class=\"outline-text-3\">\n\nThe rust book has a nice <a href=\"https:\/\/doc.rust-lang.org\/book\/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html\" data-bcup-haslogintext=\"no\">section<\/a> dedicated to this subject. The main takeaways are:\n<ol class=\"org-ol\">\n \t<li>the <code>use<\/code> keyword let you access other modules in the hierarchy: levels are separated by a double colon ::\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">std<\/span>::io;\n<\/pre>\n<\/div><\/li>\n \t<li>a module in the current project can refer to its ancestors using the <code>super<\/code> keyword at the beginning of the sequence\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #ffad29; font-weight: bold;\">super<\/span>::<span style=\"color: #008b8b;\">another<\/span>::branch;\n<\/pre>\n<\/div><\/li>\n \t<li>the root of all modules in this project is referred with the keyword crate\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #ffad29; font-weight: bold;\">crate<\/span>::sublevel;\n<\/pre>\n<\/div><\/li>\n \t<li>one or more elements can be exposed out of their modules; possible clashes can be handled using aliases\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">std<\/span>::<span style=\"color: #008b8b;\">io<\/span>::<span style=\"color: #34cae2;\">Result<\/span>;\n<span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">std<\/span>::<span style=\"color: #008b8b;\">io<\/span>::{<span style=\"color: #ffad29; font-weight: bold;\">self<\/span>, <span style=\"color: #34cae2;\">Write<\/span>};\n<span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">std<\/span>::<span style=\"color: #008b8b;\">fmt<\/span>::<span style=\"color: #34cae2;\">Result<\/span> <span style=\"color: #ffad29; font-weight: bold;\">as<\/span> <span style=\"color: #34cae2;\">FmtResult<\/span>;\n<\/pre>\n<\/div><\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org872dd82\" class=\"outline-2\">\n<h2 id=\"org872dd82\">mixing all together<\/h2>\n<div id=\"text-org872dd82\" class=\"outline-text-2\"><\/div>\n<div id=\"outline-container-org7696764\" class=\"outline-3\">\n<h3 id=\"org7696764\">other compilation targets<\/h3>\n<div id=\"text-org7696764\" class=\"outline-text-3\">\n\nfiles in the <code>examples<\/code> and <code>tests<\/code> are compiled according to the appropriate target\n<pre id=\"nil\" class=\"example\">projectdir\/\n\u251c\u2500 Cargo.toml\n\u251c\u2500 src\/\n\u2502  \u2514\u2500 lib.rs\n\u251c\u2500 examples\/\n\u2514\u2500 tests\/\n<\/pre>\ne.g. the following command\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-bash\">cargo build --example mycode\n<\/pre>\n<\/div>\nwill compile the file <code>examples\/mycode.rs<\/code>; to run it\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-bash\">cargo run --example mycode\n<\/pre>\n<\/div>\nthe test command will build and execute also the tests under the tests directory.\n\nBut now things starts to be tricky: how can you import the modules in the src directory in order to test them?\n\nthe same applies for examples\n\n<\/div>\n<\/div>\n<div id=\"outline-container-org248f786\" class=\"outline-3\">\n<h3 id=\"org248f786\">accessing the default crate from test files<\/h3>\n<div id=\"text-org248f786\" class=\"outline-text-3\">\n\nsuppose we have the following function in our library\n<div class=\"org-src-container\"><label class=\"org-src-name\"><em> Name: my-func.<\/em><\/label>\n<pre id=\"my-func\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">pub<\/span> <span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">myfunc<\/span>(){}\n<\/pre>\n<\/div>\nthe crate name is taken from the Cargo.toml name attribute\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">rust_blog<\/span>;\n<span style=\"color: #23d7d7;\">#[test]<\/span>\n<span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">test_access_base<\/span>(){\n    <span style=\"color: #008b8b;\">rust_blog<\/span>::myfunc();\n}\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-org4d675af\" class=\"outline-3\">\n<h3 id=\"org4d675af\">accessing modules from different files<\/h3>\n<div id=\"text-org4d675af\" class=\"outline-text-3\">\n\nthe following syntax, added to the lib.rs file is doing two actions:\n<ul class=\"org-ul\">\n \t<li>the mod command search for a file (in this case in the current directory)<\/li>\n \t<li>the pub modifier re-exports the command<\/li>\n<\/ul>\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">pub<\/span> <span style=\"color: #ffad29; font-weight: bold;\">mod<\/span> <span style=\"color: #008b8b;\">poly<\/span>;\n<\/pre>\n<\/div>\n<ul class=\"org-ul\">\n \t<li>this allows to add a test file like the following: note that this looks for a <code>src\/lib.rs<\/code> which in turn redirects to <code>src\/poly.rs<\/code> file<\/li>\n<\/ul>\n<div class=\"org-src-container\"><label class=\"org-src-name\"><\/label>\n<pre id=\"nil\" class=\"src src-rust\"><span style=\"color: #ffad29; font-weight: bold;\">use<\/span> <span style=\"color: #008b8b;\">rust_blog<\/span>::poly;\n\n<span style=\"color: #ffad29; font-weight: bold;\">mod<\/span> <span style=\"color: #008b8b;\">test<\/span> {\n    <span style=\"color: #23d7d7;\">#[test]<\/span>\n    <span style=\"color: #ffad29; font-weight: bold;\">fn<\/span> <span style=\"color: #00ede1; font-weight: bold;\">it_works<\/span>() {\n        <span style=\"color: #23d7d7;\">assert_eq!<\/span>(2 + 2, 4);\n    }\n}\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"How cargo lays files in a project impacts on Rust modules import when compiling tests and examples","protected":false},"author":1,"featured_media":61,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[5],"class_list":["post-21","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-language-learning","tag-rust"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Crates and cargo - Noise On The Net<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Crates and cargo - Noise On The Net\" \/>\n<meta property=\"og:description\" content=\"How cargo lays files in a project impacts on Rust modules import when compiling tests and examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/\" \/>\n<meta property=\"og:site_name\" content=\"Noise On The Net\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-24T20:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-25T09:41:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"marco.p.v.vezzoli\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"marco.p.v.vezzoli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/\"},\"author\":{\"name\":\"marco.p.v.vezzoli\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#\\\/schema\\\/person\\\/88c3a70f2b23480197bc61d6e1e2e982\"},\"headline\":\"Crates and cargo\",\"datePublished\":\"2022-01-24T20:14:00+00:00\",\"dateModified\":\"2022-01-25T09:41:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/\"},\"wordCount\":725,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#\\\/schema\\\/person\\\/88c3a70f2b23480197bc61d6e1e2e982\"},\"image\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/noiseonthenet.space\\\/noise\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1\",\"keywords\":[\"Rust\"],\"articleSection\":[\"Language learning\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/\",\"url\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/\",\"name\":\"Crates and cargo - Noise On The Net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/noiseonthenet.space\\\/noise\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1\",\"datePublished\":\"2022-01-24T20:14:00+00:00\",\"dateModified\":\"2022-01-25T09:41:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/noiseonthenet.space\\\/noise\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/noiseonthenet.space\\\/noise\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1\",\"width\":1920,\"height\":1280},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/2022\\\/01\\\/crates-and-cargo\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Crates and cargo\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#website\",\"url\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/\",\"name\":\"Noise On The Net\",\"description\":\"Sharing adventures in code\",\"publisher\":{\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#\\\/schema\\\/person\\\/88c3a70f2b23480197bc61d6e1e2e982\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/#\\\/schema\\\/person\\\/88c3a70f2b23480197bc61d6e1e2e982\",\"name\":\"marco.p.v.vezzoli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g\",\"caption\":\"marco.p.v.vezzoli\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g\"},\"description\":\"Self taught assembler programming at 11 on my C64 (1983). Never stopped since then -- always looking up for curious things in the software development, data science and AI. Linux and FOSS user since 1994. MSc in physics in 1996. Working in large semiconductor companies since 1997 (STM, Micron) developing analytics and full stack web infrastructures, microservices, ML solutions\",\"sameAs\":[\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/marco-paolo-valerio-vezzoli-0663835\\\/\"],\"url\":\"https:\\\/\\\/noiseonthenet.space\\\/noise\\\/author\\\/marco-p-v-vezzoli\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Crates and cargo - Noise On The Net","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/","og_locale":"en_US","og_type":"article","og_title":"Crates and cargo - Noise On The Net","og_description":"How cargo lays files in a project impacts on Rust modules import when compiling tests and examples","og_url":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/","og_site_name":"Noise On The Net","article_published_time":"2022-01-24T20:14:00+00:00","article_modified_time":"2022-01-25T09:41:18+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg","type":"image\/jpeg"}],"author":"marco.p.v.vezzoli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"marco.p.v.vezzoli","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#article","isPartOf":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/"},"author":{"name":"marco.p.v.vezzoli","@id":"https:\/\/noiseonthenet.space\/noise\/#\/schema\/person\/88c3a70f2b23480197bc61d6e1e2e982"},"headline":"Crates and cargo","datePublished":"2022-01-24T20:14:00+00:00","dateModified":"2022-01-25T09:41:18+00:00","mainEntityOfPage":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/"},"wordCount":725,"commentCount":0,"publisher":{"@id":"https:\/\/noiseonthenet.space\/noise\/#\/schema\/person\/88c3a70f2b23480197bc61d6e1e2e982"},"image":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1","keywords":["Rust"],"articleSection":["Language learning"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/","url":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/","name":"Crates and cargo - Noise On The Net","isPartOf":{"@id":"https:\/\/noiseonthenet.space\/noise\/#website"},"primaryImageOfPage":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#primaryimage"},"image":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1","datePublished":"2022-01-24T20:14:00+00:00","dateModified":"2022-01-25T09:41:18+00:00","breadcrumb":{"@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#primaryimage","url":"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1","contentUrl":"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1","width":1920,"height":1280},{"@type":"BreadcrumbList","@id":"https:\/\/noiseonthenet.space\/noise\/2022\/01\/crates-and-cargo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/noiseonthenet.space\/noise\/"},{"@type":"ListItem","position":2,"name":"Crates and cargo"}]},{"@type":"WebSite","@id":"https:\/\/noiseonthenet.space\/noise\/#website","url":"https:\/\/noiseonthenet.space\/noise\/","name":"Noise On The Net","description":"Sharing adventures in code","publisher":{"@id":"https:\/\/noiseonthenet.space\/noise\/#\/schema\/person\/88c3a70f2b23480197bc61d6e1e2e982"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/noiseonthenet.space\/noise\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/noiseonthenet.space\/noise\/#\/schema\/person\/88c3a70f2b23480197bc61d6e1e2e982","name":"marco.p.v.vezzoli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g","caption":"marco.p.v.vezzoli"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/b9d9aab1df560bc14d73b0b442198f196ce39e7c7a38df1dc22fec0b97f17da9?s=96&d=mm&r=g"},"description":"Self taught assembler programming at 11 on my C64 (1983). Never stopped since then -- always looking up for curious things in the software development, data science and AI. Linux and FOSS user since 1994. MSc in physics in 1996. Working in large semiconductor companies since 1997 (STM, Micron) developing analytics and full stack web infrastructures, microservices, ML solutions","sameAs":["https:\/\/noiseonthenet.space\/noise\/","https:\/\/www.linkedin.com\/in\/marco-paolo-valerio-vezzoli-0663835\/"],"url":"https:\/\/noiseonthenet.space\/noise\/author\/marco-p-v-vezzoli\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/noiseonthenet.space\/noise\/wp-content\/uploads\/2022\/01\/kelli-mcclintock-DcoB_NoNl6U-unsplash-2.jpg?fit=1920%2C1280&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pdDUZ5-l","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":5,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/posts\/21\/revisions\/68"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/media\/61"}],"wp:attachment":[{"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/noiseonthenet.space\/noise\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}