{"id":2235,"date":"2022-02-24T08:38:53","date_gmt":"2022-02-24T14:38:53","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=2235"},"modified":"2022-04-25T09:32:42","modified_gmt":"2022-04-25T14:32:42","slug":"rust-string-vs-str","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-string-vs-str\/","title":{"rendered":"String vs str in Rust: Understanding the difference"},"content":{"rendered":"\n<p>If you have a background in a different programming language and you are learning Rust, one of the first questions you might ask is: <em>What is the difference between a String and a str in Rust<\/em>? It is easy to let our brains fool ourselves as it would typically relate a str with the word &#8220;string&#8221;. Hence, it is easy to get confused with str as String, but is a String a . Hopefully, this article has everything you need to differentiate between these two types in Rust.<\/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-string-vs-str\/#What_is_str\" >What is str?<\/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-string-vs-str\/#What_is_a_string_literal\" >What is a string literal?<\/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-string-vs-str\/#What_is_a_string_slice\" >What is a string slice?<\/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-string-vs-str\/#Common_to_find_a_str_in_its_borrowed_state\" >Common to find a str in its borrowed state<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-string-vs-str\/#What_is_a_String\" >What is a String?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-string-vs-str\/#What_are_the_differences_between_str_and_String\" >What are the differences between str and String?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-string-vs-str\/#Understanding_the_difference_can_have_an_impact_in_the_performance_and_behavior_of_the_program\" >Understanding the difference can have an impact in the performance and behavior of the program<\/a><\/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-string-vs-str\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"what-is-str\"><span class=\"ez-toc-section\" id=\"What_is_str\"><\/span>What is str?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>A str is a primitive type in Rust, and it represents a string literal<\/strong>, <strong>and it&#8217;s data is allocated in the data segment of the application binary<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-a-string-literal\"><span class=\"ez-toc-section\" id=\"What_is_a_string_literal\"><\/span>What is a string literal?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A string literal is a string slice or a sequence of characters enclosed by double quotes (<code>\"\"<\/code>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-a-string-slice\"><span class=\"ez-toc-section\" id=\"What_is_a_string_slice\"><\/span>What is a string slice?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A slice represents a view containing a sequence of elements and it is represented with the syntax <code>[T]<\/code>. Slices don&#8217;t have ownership, but they let you reference the sequence of elements.<\/p>\n\n\n\n<p>Hence, <strong>a<\/strong> <strong>string slice is the reference of a sequence of elements of a string<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let my_string = String::from(\"Learning Rust\");\n\nlet my_slice = &amp;my_string&#91;0..8];<\/code><\/pre>\n\n\n\n<p>Notice in the previous example how we get the reference of a String, which is the collection. This might not be that clear at first. That&#8217;s why we will break down the <code>my_string<\/code> variable.<\/p>\n\n\n\n<p>The <code>my_string<\/code> variable contains the characters <code>Learning Rust<\/code>. Each character has a place or index in the String, which is a growable array.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"309\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2022\/02\/String-breakdown.png\" alt=\"\" class=\"wp-image-2236\" title=\"String is a growable array\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/02\/String-breakdown.png 656w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/02\/String-breakdown-300x141.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><figcaption>String is a growable array<\/figcaption><\/figure><\/div>\n\n\n\n<p>Hence, when using <code>&amp;my_string[0..8]<\/code>, Rust gets the reference of the pointer of the String <code>my_string<\/code> between 0 and 8, which results in the sequence <code>Learning<\/code>.<\/p>\n\n\n\n<p>Although a string slice often represents a subsequence of elements of String, that doesn&#8217;t prevent from getting the whole sequence of elements of a String.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let my_string = String::from(\"Learning Rust\");\n\nlet my_slice = &amp;my_string&#91;..];\n\n\/\/ the following are equivalent to the above statement\nlet my_slice = &amp;my_string&#91;..];\nlet my_slice = &amp;my_string&#91;0..13];\nlet my_slice = &amp;my_string&#91;..13];<\/code><\/pre>\n\n\n\n<p>In this case, the <code>my_slice<\/code> variable cointains the characters <code>Learning Rust<\/code>.  <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"common-to-find-a-str-in-its-borrowed-state\"><span class=\"ez-toc-section\" id=\"Common_to_find_a_str_in_its_borrowed_state\"><\/span>Common to find a str in its borrowed state<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Typically, the str is found preceded by <code>&amp;<\/code>, which in other words is <code>&amp;str<\/code> or the borrowing state of a str in Rust. For example, whenever we generate a str and assign it to a variable, the variable is a <code>&amp;str<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let country = \"Colombia\";\n\n\/\/ this is the equivalent of the above statement\nlet country: &amp;str = \"Colombia\";<\/code><\/pre>\n\n\n\n<p>This might be confusing at first as you might think the variable <code>country<\/code> is a str. However, there is not a way to have a str variable without the <code>&amp;<\/code> or in its borrowed state as str(s) are string slices, and slices don&#8217;t have ownership as previously mentioned. Hence, the str itself is <code>Colombia<\/code> which is already a sequence of elements or a string slice. However, the <code>country<\/code> variable holds the reference of <code>Colombia<\/code>, which is allocated in the application binary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-a-string\"><span class=\"ez-toc-section\" id=\"What_is_a_String\"><\/span>What is a String?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>A String is a struct containing a vector <code>Vec<\/code>, or growable 8-bit unsigned array <\/strong>like you can see in the snippet of code below. You can also find the struct definition <a href=\"https:\/\/github.com\/rust-lang\/rust\/blob\/master\/library\/alloc\/src\/string.rs\" target=\"_blank\" rel=\"noreferrer noopener\">by checking the Rust open source library<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>pub struct String {\n    vec: Vec&lt;u8&gt;\n}<\/code><\/pre>\n\n\n\n<p>Contrary to str, a String has ownerhip of the data, which means it is not necessary to use <code>&amp;<\/code> or borrowing state when defining the value of a String to a variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let my_string = String::from(\"Understanding the String concept?\");\n\n\/\/ this is the equivalent of the above statement\nlet my_string: String = String::from(\"Understanding the String concept?\");<\/code><\/pre>\n\n\n\n<p>The size of a String can be known or unknown at compile time during its initialization, but it can grow as the length of the String reaches its capacity. For instance, in the previous example <code>my_string<\/code> didn&#8217;t have a known capacity until Rust figures out how many characters are in the string sequence.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let mut my_string = String::from(\"Understanding the String concept?\"); \/\/ capacity is 33, length is 33\n my_string = \"Hello!\".to_string(); \/\/ capacity is 6, length is 6<\/code><\/pre>\n\n\n\n<p>However, in the following example, we define the capacitity when initilizing the String using <code>with_capacity<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let mut my_string = String::with_capacity(3);\nmy_string.push('a'); \/\/ capacity is 3, length is 1\nmy_string.push('b'); \/\/ capacity is 3, length is 2\nmy_string.push('c'); \/\/ capacity is 3, length is 3\nmy_string.push('d'); \/\/ capacity could double, length is 4<\/code><\/pre>\n\n\n\n<p><strong>Everytime the capacity is updated, data needs to be reallocated which results in an expensive operation.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-are-the-differences-between-str-and-string\"><span class=\"ez-toc-section\" id=\"What_are_the_differences_between_str_and_String\"><\/span>What are the differences between str and String?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Hopefully, you noticed some differences when learning the definition of a str and a String. However, the following table shows side-by-side key differences between these two types.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table class=\"has-fixed-layout\"><thead><tr><th>str<\/th><th>String<\/th><\/tr><\/thead><tbody><tr><td>Primitive Type<\/td><td>Built-in struct<\/td><\/tr><tr><td>Doesn&#8217;t have ownership of the string as it is typically used by reference<\/td><td>Has ownership of the string<\/td><\/tr><tr><td>It is a string slice<\/td><td>It is a growable array<\/td><\/tr><tr><td>Size known at compile time<\/td><td>Size is unknown at compile time<\/td><\/tr><tr><td>Data allocated in the data segment of the application binary<\/td><td>Data allocated in a heap<\/td><\/tr><tr><td>Uses &amp; or reference to assign a str value to a variable <\/td><td>Not need need to use &amp; or reference to assign a String value to a variable  <\/td><\/tr><\/tbody><\/table><figcaption>Comparison between str and String<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-the-difference-can-have-an-impact-in-the-performance-and-behavior-of-the-program\"><span class=\"ez-toc-section\" id=\"Understanding_the_difference_can_have_an_impact_in_the_performance_and_behavior_of_the_program\"><\/span>Understanding the difference can have an impact in the performance and behavior of the program<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While Rust programs typically outperform other applications developed in different programming languages, that doesn&#8217;t mean we shouldn&#8217;t be aware of what to look for to our Rust application better.<\/p>\n\n\n\n<p>For example, a str is often used in its borrowed state as function parameters.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_string = String::from(\"Understanding the String concept?\");\n \n    print_data(&amp;my_string);\n}\n\nfn  print_data(data: &amp;str) {\n   println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p><strong>Note<\/strong>: it might confusing at first to see we are passing the reference of a String when calling <code>print_data<\/code> function when <code>data<\/code> parameter expects a <code>&amp;str<\/code>. A <code>&amp;String<\/code> can automatically convert into a <code>&amp;str<\/code>.<\/p>\n\n\n\n<p>This allows us to pass only the reference of the String to the <code>print_data<\/code> function and remain accessible inside the main function as the String is not <em>moved<\/em>. In other words, the term <em>moved <\/em>means to transfer ownership.<\/p>\n\n\n\n<p>Let&#8217;s take a look at another example. In this case, the code won&#8217;t compile.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_string = String::from(\"Understanding the String concept?\");\n \n    print_data(my_string); \/\/ ownership of my_string is transfered\n\n    print!(\"printing inside main {}\", my_string); \/\/ error at compile time here \n}\n\nfn  print_data(data: String) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>Notice there are couple of changes from the previous example:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The  <code>print_data<\/code> function accepts a <code>data<\/code> parameter of a type <code>String<\/code><\/li><li>Attempt to print the values of <code>my_string<\/code> inside the <code>main<\/code> function<\/li><\/ol>\n\n\n\n<p>The reason why that code won&#8217;t compile is the String <code>my_string<\/code> initial ownership was in the <code>main<\/code> function. However, since the <code>print_data<\/code> functions accepts as a parameter the String and not a reference of a string, the ownership will be transfered to <code>print_data<\/code> function, making <code>my_string<\/code> no longer available in the <code>main<\/code> function.<\/p>\n\n\n\n<p>To fix this, we modify the type of <code>data<\/code> to accept a reference of a String instead. This will force use pass the reference of <code>my_string<\/code> when calling the <code>print_data<\/code> function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_string = String::from(\"Understanding the String concept?\");\n \n    print_data(&amp;my_string); \/\/ my_string is borrowed\n\n    print!(\"printing inside main {}\", my_string); \n}\n\nfn  print_data(data: &amp;String) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>You might think: Why would I want to have the <code>data<\/code> parameter defined between <code>&amp;str<\/code> or <code>&amp;String<\/code>?<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>\/\/ what to choose?\n\/\/ 1. data: &amp;String \nfn  print_data(data: &amp;String) {\n    println!(\"printing my data {} \", data);\n}\n\n\/\/ 2. or data: &amp;str\nfn  print_data(data: &amp;str) {\n   println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>Making a decision between the two options in a small program like this will probably not matter much. However, it is all about understanding the fundamentals of the programming language. We will analyze each option.<\/p>\n\n\n\n<p>Let&#8217;s start analyzing option 1, or using <code>&amp;String<\/code> as the type of <code>data<\/code> parameter. Remember when we used this alternative, the variable <code>my_string<\/code> in the <code>main<\/code> was a String type.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_string = String::from(\"Understanding the String concept?\");\n \n    print_data(&amp;my_string);\n\n    print!(\"printing inside main {}\", my_string); \n}\n\nfn  print_data(data: &amp;String) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>We only had to pass the reference <code>my_string<\/code> to trigger <code>print_data<\/code> function, which means <code>my_string<\/code> still has the ownership of the data in a heap.<\/p>\n\n\n\n<p>However, what if we make a change in the code, and instead of defining a <code>my_string<\/code> variable, we define a <code>my_str<\/code> variable, where <code>my_str<\/code> has a type of <code>&amp;str<\/code>? <\/p>\n\n\n\n<p>Assume we are going to call the <code>print_data<\/code> function using the borrowed data of <code>my_str<\/code>. However, it wouldn&#8217;t be possible to do this operation unless we generate a <code>String<\/code> off of the string literal borrowed in <code>my_str<\/code>, as <code>print_data<\/code> only accepts <code>data<\/code> parameter of type <code>&amp;String<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_str = \"This is a str\";\n\n    \/\/ converting the str to String is an expensive operation\n    print_data(&amp;my_str.to_string()); \n \n    print!(\"printing inside main {}\", my_str); \n}\n\nfn  print_data(data: &amp;String) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>When using <code>&amp;my_str.to_string()<\/code>, data is still passed by reference (<code>&amp;<\/code>). However, there&#8217;s also data allocation in a heap as we make it a <code>String<\/code>, which is itself an expensive operation when compared to only passing the reference.<\/p>\n\n\n\n<p>Let&#8217;s look at option 2, or using <code>&amp;str<\/code> as the type of data parameter. We are going to start with using <code>my_string<\/code> variable which has a type of <code>String<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() {\n    let my_string = String::from(\"Understanding the String concept?\");\n \n    print_data(&amp;my_string);\n\n    print!(\"printing inside main {}\", my_string); \n}\n\nfn  print_data(data: &amp;str) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>Notice we only needed to pass the borrowed state of <code>my_string<\/code> to <code>print_data<\/code> as <code>String<\/code> can convert to a string slice automatically. This process requires only to pass the reference. At this point we haven&#8217;t allocated any additional data in the heap besides the string literal stored in <code>my_string.<\/code><\/p>\n\n\n\n<p>Now, let&#8217;s change <code>my_string<\/code> to use a <code>&amp;str<\/code> variable called <code>my_str<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code> fn main() {\n    let my_str = \"This is a str\";\n \n    print_data(my_str);\n\n    print!(\"printing inside main {}\", my_str); \n}\n\nfn  print_data(data: &amp;str) {\n    println!(\"printing my data {} \", data);\n}<\/code><\/pre>\n\n\n\n<p>In this case, we are only passing the reference of <code>my_str<\/code>.<\/p>\n\n\n\n<p>Notice how there&#8217;s an impact in performance when using <code>data: &amp;String<\/code> or <code>data: &amp;str<\/code>. Typically, <strong>the type <code>&amp;str<\/code> is useful when passed as a function parameter as there is no need to create a copy into another <code>String<\/code> <\/strong>.<\/p>\n\n\n\n<p>However, that doesn&#8217;t mean you should always have function parameters with the type of <code>&amp;str<\/code>. It all comes down to what you are intending to achieve in your Rust program.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>All in all, understanding the differences between a str and a String is a challenge itself. Knowing a str is a primitive type and a String is a built-in struct, doesn&#8217;t help much when deciding what to choose in our code. <\/p>\n\n\n\n<p>Also, learning the differences between the two allows us to get a deeper understanding of how the Rust programming language works and getting a good grasp of concepts such as <a href=\"https:\/\/doc.rust-lang.org\/book\/ch04-01-what-is-ownership.html\" target=\"_blank\" rel=\"noreferrer noopener\">ownership<\/a>, which main purpose is to optimize memory management. This can make a difference in the performance of your program, even when making little changes in the code.<\/p>\n\n\n\n<p><strong>Was this article helpful?<\/strong><\/p>\n\n\n\n<p><strong>I hope this article helped you to clarify doubts and concepts of Rust, especially to those new to the programming language<\/strong>.<\/p>\n\n\n\n<p>Share your thoughts by replying on Twitter of <a href=\"https:\/\/twitter.com\/bbprogrammer\" target=\"_blank\" rel=\"noreferrer noopener\">Become A Better Programmer<\/a> or to <a href=\"https:\/\/twitter.com\/arealesramirez\" target=\"_blank\" rel=\"noreferrer noopener\">personal my Twitter account<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-rich is-provider-twitter wp-block-embed-twitter\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"twitter-tweet\" data-width=\"550\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">We are back with another article about <a href=\"https:\/\/twitter.com\/hashtag\/rustlang?src=hash&amp;ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">#rustlang<\/a>.<br><br>This time we talk about the differences between a String and an str<br><br>&#8230;which is challenging for those who are learning <a href=\"https:\/\/twitter.com\/hashtag\/Rust?src=hash&amp;ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">#Rust<\/a> <a href=\"https:\/\/t.co\/feAa3qkmgQ\">https:\/\/t.co\/feAa3qkmgQ<\/a><\/p>&mdash; Become A Better Programmer (@bbprogrammer) <a href=\"https:\/\/twitter.com\/bbprogrammer\/status\/1496858092180545546?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">February 24, 2022<\/a><\/blockquote><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Learning the difference between a String and a str in Rust can be challenging, In this article, we explain each concept with easy-to-follow examples.<\/p>\n","protected":false},"author":1,"featured_media":2244,"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-2235","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\/2235","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=2235"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/2235\/revisions"}],"predecessor-version":[{"id":2452,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/2235\/revisions\/2452"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/2244"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=2235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=2235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=2235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}