{"id":3880,"date":"2022-08-30T21:57:15","date_gmt":"2022-08-31T02:57:15","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=3880"},"modified":"2022-08-30T21:57:21","modified_gmt":"2022-08-31T02:57:21","slug":"rust-copy-vs-clone-trait","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/","title":{"rendered":"Rust | What Is The Difference Between Copy and Clone Trait?"},"content":{"rendered":"\n<p>As you learn more about Rust programming language, you find out functionalities that seem to work the same, when in reality they differ in subtle ways. This is the case for the <code>Copy<\/code> and <code>Clone<\/code> traits. This article will explain each trait and show you what makes each different from the otehr.<\/p>\n\n\n\n<p>In Rust, the <code>Copy<\/code> and <code>Clone<\/code> traits main function is to generate duplicate values. <strong>The difference is that <code>Copy<\/code> implicitly generates duplicates off of the bits of an existing value, and <code>Clone<\/code> explicitly generates deep copies of an existing value, often resulting in a more expensive and less performant operation that duplicating values via the <code>Copy<\/code> trait.<\/strong><\/p>\n\n\n\n<p>This post will explain how the <code>Copy<\/code> and <code>Clone<\/code> traits work, how you can implement them when using  custom types, and display a comparison table between these two traits to give you a better understanding of the differences and similarities between the two.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#How_The_Copy_Trait_Works\" >How The Copy Trait Works<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Copying_0s_and_1s\" >Copying 0s and 1s<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Implicit_Duplicate\" >Implicit Duplicate<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Not_All_Rust_Values_Can_Copy_their_own_values\" >Not All Rust Values Can Copy their own values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#How_to_Implement_the_Copy_Trait\" >How to Implement the Copy Trait<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Use_the_derive_attribute_to_add_Clone_and_Copy\" >Use the #[derive] attribute to add Clone and Copy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Manually_add_Copy_and_Clone_implementations_to_the_Struct\" >Manually add Copy and Clone implementations to the Struct<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#How_the_Clone_Trait_Works\" >How the Clone Trait Works<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#How_to_Implement_the_Clone_Trait\" >How to Implement the Clone Trait<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Use_the_derive_attribute_to_add_Clone\" >Use the #[derive] attribute to add Clone<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Manually_add_a_Clone_implementation_to_the_Struct\" >Manually add a Clone implementation to the Struct<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Comparison_Between_Copy_and_Clone_Traits\" >Comparison Between Copy and Clone Traits<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_The_Copy_Trait_Works\"><\/span>How The <code>Copy<\/code> Trait Works<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>As previously mentioned, the <code>Copy<\/code> trait generates an implicit duplicate of a value by copying its bits.<\/p>\n\n\n\n<p><em>What does this mean?<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Copying_0s_and_1s\"><\/span>Copying 0s and 1s<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Information is stored in bits and bytes. A byte is a collection of 8 bits and a bit is either a 0 or a 1.  Every time you have a value, whether it is a boolean, a number, a string, etc, the value is stored in unique byte configuration representing that value.<\/p>\n\n\n\n<p>In other words, if you have the values, such as,<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>true<\/code><\/li><li><code>false<\/code><\/li><li><code>1<\/code><\/li><li><code>-5<\/code><\/li><li><code>\"hello\"<\/code><\/li><\/ul>\n\n\n\n<p>to name a few, each value has a collection of bits that denotes their value.<\/p>\n\n\n\n<p>Hence, <strong>when you generate a duplicate using the <code>Copy<\/code> trait, what happens behind the scenes is copying the collection of 0s and 1s of the given value.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Implicit_Duplicate\"><\/span>Implicit Duplicate<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>One of the key words you see in the definition of the <code>Copy<\/code> trait is the word &#8220;implicit&#8221;.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>The <code>Copy<\/code> trait generates an implicit duplicate of a value by copying its bits<\/p><cite>For more information, check the Rust documentation: <a href=\"https:\/\/doc.rust-lang.org\/core\/marker\/trait.Copy.html\" target=\"_blank\" rel=\"noopener\">Trait core::marker::Copy<\/a><\/cite><\/blockquote>\n\n\n\n<p>This means, there is no need to trigger a method, .i.e., <code>.copy()<\/code> to generate a duplicate value. Meaning, the duplicate happens if you have a regular assignment like:<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let duplicate_value = value; <\/code><\/pre>\n\n\n\n<p>where <code>duplicate_value<\/code> variable gets a copy of the values stored in the <code>value<\/code> variable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Not_All_Rust_Values_Can_Copy_their_own_values\"><\/span>Not All Rust Values Can <code>Copy<\/code> their own values<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>One of the most important concepts of Rust is <a href=\"https:\/\/doc.rust-lang.org\/book\/ch04-00-understanding-ownership.html\" target=\"_blank\" rel=\"noopener\">Ownership and Borrowing<\/a>, which provides memory management different from the traditional <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/garbage-collection\/fundamentals\" target=\"_blank\" rel=\"noopener\">garbage collector<\/a> mechanism.<\/p>\n\n\n\n<p>The ownership and borrowing system makes Rust&#8217;s standard behavior to &#8220;move&#8221; the ownership between the two variables. This is referred as &#8220;move semantics&#8221;. Take a look at the following example:<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>#&#91;derive(Debug)]\nstruct Team {}\n\nfn main() {\n   let my_team = Team {};\n   let my_duplicate_team = my_team;\n\n   println!(\"my_team = {my_team:?}, my_duplicate_team = {my_duplicate_team:?}\"); \n}<\/code><\/pre>\n\n\n\n<p>If you try to run the previous code snippet, Rust will throw the following compile error:<\/p>\n\n\n\n<p><code>error[E0382]: borrow of moved value: my_team<\/code><\/p>\n\n\n\n<p>This has to do with Rust&#8217;s ownership system. Meaning, <code>my_team<\/code> has an instance of <code>Team<\/code> . In other words, <code>my_team<\/code> is the owner of that particular instance of <code>Team<\/code>. <\/p>\n\n\n\n<p>However, whenever <code>my_duplicate_team<\/code> was assigned the values of <code>my_team<\/code>, what Rust did behind the scenes was to transfer the ownership of the instance of <code>Team<\/code> stored in <code>my_team<\/code>. Meaning, the new owner of the instance of <code>Team<\/code>  is <code>my_duplicate_team<\/code>.<\/p>\n\n\n\n<p>Since <code>my_team<\/code> no longer owns anything, what Rust&#8217;s memory management system does is to remove <code>my_team<\/code> no matter if you use <code>my_team<\/code> later on within the same function, which leads to the error previously described at compile time (<code>error[E0382]: borrow of moved value: my_team<\/code>).<\/p>\n\n\n\n<p>Now, if you have the following code,<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let number1 = 1;\n    let number2 = number1;\n\n    println!(\n        \"number 1 = {}, number 2 = {}\",\n        number1, number2\n    );\n}<\/code><\/pre>\n\n\n\n<p>and attempt to run it, Rust will successfully compile the code and print the values in <code>number1<\/code> and <code>number2<\/code>.<\/p>\n\n\n\n<p><strong><em>Why didn&#8217;t the code fail if <code>number1<\/code> transferred ownership to <code>number2<\/code> variable for the value of <\/em><code>1<\/code>?<\/strong><\/p>\n\n\n\n<p>This is a good assumption, but in this case there is no transfer of ownership. In this scenario, you are seeing the <code>Copy<\/code> trait in action as it generates a duplicate value by copying  the bits of the value <code>1<\/code> stored in <code>number1<\/code> . This is referred as <strong>&#8220;copy semantics&#8221;<\/strong>.<\/p>\n\n\n\n<p><em><strong>Wait a second. How can I know when Rust will implicitly generate a duplicate and when it will implicitly transfer ownership?<\/strong><\/em><\/p>\n\n\n\n<p>By default, Rust implements the <code>Copy<\/code> trait to certain types of values such as integer numbers, booleans, characters, floating numbers, etc. <a href=\"https:\/\/doc.rust-lang.org\/core\/marker\/trait.Copy.html#implementors\" target=\"_blank\" rel=\"noopener\">You can find a list of the types Rust implements the <code>Copy<\/code> trait by default in here<\/a>. Below you will see a list of a few of them:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"574\" height=\"910\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2022\/08\/image-4.png\" alt=\"\" class=\"wp-image-3883\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/08\/image-4.png 574w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/08\/image-4-189x300.png 189w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><figcaption>Some of the types implementing the <code>Copy<\/code>  Tait by default <\/figcaption><\/figure>\n<\/div>\n\n\n<p><em><strong>How come Rust implemented the <code>Copy<\/code> trait in those types by default?<\/strong><\/em><\/p>\n\n\n\n<p>Rust implements the <code>Copy<\/code> trait in certain types by default as the value generated from those types are the same all the time. Meaning, all integers (<code>12<\/code>), floating-point numbers (<code>3.4<\/code> ), booleans ( <code>true<\/code>, <code>false<\/code> ), and characters (<code>'a'<\/code>,  <code>'z'<\/code>) have the same value no matter how many times you use them. Hence, the collection of bits of those <code>Copy<\/code>able values are the same over time. <\/p>\n\n\n\n<p>Therefore, it is possible to determine what bits to copy to generate a duplicate value. These values have a known fixed size. Fixed-size values are stored on the stack, which is very fast when compared to values stored in the heap. Hence, making the implicit copy a fast and cheap operation of generating duplicate values.<\/p>\n\n\n\n<p>In the next section, you will learn how to implement the <code>Copy<\/code> trait for those types that are non-<code>Copy<\/code> by default such as custom structs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Implement_the_Copy_Trait\"><\/span>How to Implement the <code>Copy<\/code> Trait<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>There are two ways to implement the <code>Copy<\/code> trait to a struct that doesn&#8217;t implement it by default. You will notice that in order to add the <code>Copy<\/code> trait, the <code>Clone<\/code> trait must be implemented too. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Use_the_derive_attribute_to_add_Clone_and_Copy\"><\/span>Use the <code>#[derive]<\/code> attribute to add Clone and Copy<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>The most common way to add trait implementations is via the <code>#[derive]<\/code> attribute. To implement the <code>Copy<\/code> trait, derive <code>Clone<\/code> and <code>Copy<\/code> to a given struct.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>#&#91;derive(Clone, Copy)]\r\nstruct MyObject {\r\n    my_number: u8,\r\n}\n\r<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Manually_add_Copy_and_Clone_implementations_to_the_Struct\"><\/span>Manually add Copy and Clone implementations to the Struct<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Another option available to copy the bits of a value is by manually implementing Copy and Clone to a given struct.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>struct MyOtherObject {\r\n    test: u8,\r\n}\r\n\r\nimpl Copy for MyOtherObject {}\r\n\r\nimpl Clone for MyOtherObject {\r\n    fn clone(&amp;self) -> MyOtherObject {\r\n        *self\r\n    }\r\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_the_Clone_Trait_Works\"><\/span>How the <code>Clone<\/code> Trait Works<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Similar to the <code>Copy<\/code> trait, the <code>Clone<\/code> trait generates a duplicate value. However, the <code>Clone<\/code> trait is different from the <code>Copy<\/code> trait in the way it generates the copy. <\/p>\n\n\n\n<p>On one hand, the <code>Copy<\/code> trait acts as a &#8220;shallow&#8221; copy. On the other hand, the <code>Clone<\/code> trait acts as a &#8220;deep&#8221; copy. Deep copies are generally considered more expensive than shallow copies.<\/p>\n\n\n\n<p>The <code>Clone<\/code> trait is handy to generate duplicates ofvalues that are stored in the heap. As a reminder, values that don&#8217;t have a fixed size are stored in the heap. Some examples are  <code>String<\/code> or<code>Vec<\/code> type values.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Implement_the_Clone_Trait\"><\/span>How to Implement the <code>Clone<\/code> Trait<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The <code>Clone<\/code> trait can be implemented in a similar way you implement the <code>Copy<\/code> trait.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Use_the_derive_attribute_to_add_Clone\"><\/span>Use the <code>#[derive]<\/code> attribute to add Clone<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To implement the <code>Clone<\/code> trait, add the <code>Clone<\/code> trait using the derive attribute in a given struct.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>#&#91;derive(Clone)]\nstruct MyObject {\n    my_number: u8,\n}<\/code><\/pre>\n\n\n\n<p>In comparison to the <code>Copy<\/code> trait, notice how the <code>Clone<\/code> trait doesn&#8217;t depend on implementing other traits.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Manually_add_a_Clone_implementation_to_the_Struct\"><\/span>Manually add a Clone implementation to the Struct<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To manually add a Clone implementation, use the keyword <code>impl<\/code> followed by <code>Clone for &lt;struct><\/code> . Then, within curly braces generate a <code>clone<\/code> function that returns a <a href=\"https:\/\/doc.rust-lang.org\/reference\/expressions\/operator-expr.html#the-dereference-operator\" target=\"_blank\" rel=\"noopener\">dereferenced<\/a> value of the current struct. Below is an example of a manual implementation. <\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>struct MyOtherObject {\n    test: u8,\n}\n\nimpl Clone for MyOtherObject {\n    fn clone(&amp;self) -> MyOtherObject {\n        *self\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Comparison_Between_Copy_and_Clone_Traits\"><\/span>Comparison Between <code>Copy<\/code> and <code>Clone<\/code> Traits<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Copy Trait<\/th><th>Clone Trait<\/th><\/tr><\/thead><tbody><tr><td>Generates a &#8220;shallow&#8221; copy \/ implicit duplicate<\/td><td>Generates a &#8220;deep&#8221; copy \/ explicit duplicate<\/td><\/tr><tr><td>It is faster as it primarily copies the bits of values with known fixed size.<\/td><td>It is typically slower when duplicating values stored in the heap.<\/td><\/tr><tr><td>To implement the<code>core::marker::Copy<\/code> trait, the type must have implemented the <code>std::clone::Clone<\/code> trait.<\/td><td>It can be used as long as the type implements the <code>std::clone::Clone<\/code> trait.<\/td><\/tr><tr><td>There <code>.copy()<\/code> method does not exist. The duplicate is implicitly generated, .i.e, assuming <code>x<\/code> derives the <code>Copy<\/code> trait:<br><code>x = 1;<\/code><br><code>y = x;<\/code><br><br><code>y<\/code> gets an duplicate of<code>x<\/code> .<\/td><td>There is a <code>.clone()<\/code> method available to the type <code>T<\/code> if <code>T<\/code> derives the <code>Clone<\/code> trait. For instance, assuming <code>x<\/code> derives the <code>Clone<\/code> trait:<br><code>x = 1;<\/code><br><code>y = x.clone(); <\/code><br><br><code>y<\/code> gets a duplicate of <code>x<\/code> .<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>All in all, this article covered the differences between the <code>Copy<\/code> and <code>Clone<\/code> traits whose main purpose is to generate duplicate values. <\/p>\n\n\n\n<p>On one hand, the <code>Copy<\/code> trait implicitly copies the bits of values with a known fixed size. Hence, there is no need to use a method such as <code>.copy()<\/code>  (in fact, that method doesn&#8217;t exist). On the other hand, to use the <code>Clone<\/code> trait, you must explicitly call the <code>.clone()<\/code>  method to generate a duplicate value.<\/p>\n\n\n\n<p><strong>Did this article help you understand the differences between the <code>Clone<\/code> and <code>Copy<\/code> trait?<\/strong><\/p>\n\n\n\n<p>Share your comments by replying on <a href=\"https:\/\/twitter.com\/bbprogrammer\" target=\"_blank\" rel=\"noopener\">Twitter of Become A Better Programmer<\/a> or to <a href=\"https:\/\/twitter.com\/arealesramirez\" target=\"_blank\" rel=\"noopener\">my personal Twitter account<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you learn more about Rust programming language, you find out functionalities that seem to work the same, when in reality they differ in subtle ways. This is the case for the Copy and Clone traits. This article will explain each trait and show you what makes each different from the otehr. In Rust, the &#8230; <a title=\"Rust | What Is The Difference Between Copy and Clone Trait?\" class=\"read-more\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-copy-vs-clone-trait\/\" aria-label=\"More on Rust | What Is The Difference Between Copy and Clone Trait?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":3951,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[31],"tags":[],"class_list":["post-3880","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rust","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=3880"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3880\/revisions"}],"predecessor-version":[{"id":3954,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3880\/revisions\/3954"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/3951"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=3880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=3880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=3880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}