[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"categories-en":3,"post:\u002Fpost\u002Fmemory-management-in-rust-ownership-borrowing-and-lifetimes-demystified":37},[4,11,17,24,30],{"id":5,"slug":6,"name":7,"colorHex":8,"iconName":9,"postCount":10},"0e2c1225-f78a-4c20-8c93-998ab9dc93b9","frontend","Frontend","#40484f",null,25,{"id":12,"slug":13,"name":14,"colorHex":15,"iconName":9,"postCount":16},"bc8df70e-b7fb-4d89-a80c-fd458d36d58c","code-development","Code & Development","#8b5cf6",23,{"id":18,"slug":19,"name":20,"colorHex":21,"iconName":22,"postCount":23},"550e8400-e29b-41d4-a716-446655440001","inteligencia-artificial","Artificial Intelligence","#6366f1","brain",14,{"id":25,"slug":26,"name":27,"colorHex":28,"iconName":9,"postCount":29},"ea63b69c-2eb4-4100-81f3-70ce52d33743","tech-news","Tech News","#e50606",4,{"id":31,"slug":32,"name":33,"colorHex":34,"iconName":35,"postCount":36},"550e8400-e29b-41d4-a716-446655440017","how-to-guides","How-To & Guides","#be123c","book-open",2,{"post":38,"related":587,"translations":663,"resolved":9},{"id":39,"slug":40,"title":41,"excerpt":42,"image":43,"featured":44,"groupId":45,"publishedAt":46,"readingTime":47,"views":48,"author":49,"category":51,"tags":52,"contentJson":65,"metaTitle":584,"metaDescription":585,"updatedAt":586},"0354c063-6a77-4aff-9faf-9f6022afdf91","memory-management-in-rust-ownership-borrowing-and-lifetimes-demystified","Memory management in Rust: ownership, borrowing, and lifetimes demystified","C gives you total control—and a loaded gun. Go uses a Garbage Collector—and latency spikes. Rust ensures memory safety at compile time, zero cost.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1774011623570-featured-o98cys.jpeg",false,"87be32c3-0bf4-480a-9bf4-40d764bc4aee","2026-06-18T23:56:26.873788+00:00",7,0,{"name":50,"avatar":9},"Genildo Souza",{"slug":13,"name":14,"color":15},[53,56,59,62],{"slug":54,"name":55},"go","Go",{"slug":57,"name":58},"lifetimes","Lifetimes",{"slug":60,"name":61},"ownership","Ownership",{"slug":63,"name":64},"rust","Rust",{"type":66,"content":67},"doc",[68,79,93,118,179,187,193,210,216,224,230,257,265,271,277,289,296,305,311,318,325,331,354,375,383,395,402,409,427,448,456,462,536,543,550,557,569,581],{"type":69,"attrs":70,"content":72},"heading",{"id":71,"level":36},"h_kc7il3lq",[73],{"text":74,"type":75,"marks":76},"The problem that every language solves differently","text",[77],{"type":78},"bold",{"type":80,"attrs":81,"content":83},"paragraph",{"id":82},"p_pp8hod28",[84,86,91],{"text":85,"type":75},"Every language needs to answer a fundamental question: ",{"text":87,"type":75,"marks":88},"when can the memory a value occupied be freed?",[89],{"type":90},"italic",{"text":92,"type":75}," The answer defines everything — performance, security, predictability.",{"type":94,"attrs":95,"content":99},"callout",{"id":96,"type":97,"title":98},"call_d4t7c50v","note","The Fundamental Memory Management Question",[100,106,112],{"type":80,"attrs":101,"content":103},{"id":102},"p_cu01zul6",[104],{"text":105,"type":75},"Every programming language must decide when memory can be freed, impacting performance, safety, and developer responsibility.",{"type":80,"attrs":107,"content":109},{"id":108},"p_6p2i4i4y",[110],{"text":111,"type":75},"Manual management (C\u002FC++) offers control but risks leaks, double frees, and use-after-free errors, causing many vulnerabilities.",{"type":80,"attrs":113,"content":115},{"id":114},"p_i8vifkxt",[116],{"text":117,"type":75},"Garbage collection (Go) automates freeing but causes unpredictable pauses, while Rust’s ownership model enforces safe, precise memory freeing at compile time without runtime costs.",{"type":119,"attrs":120,"content":122},"compare",{"id":121},"cmp_mzet2pfg",[123,147,163],{"type":124,"attrs":125,"content":129},"compareColumn",{"id":126,"side":127,"title":128},"col_4sv31tcj","left","C \u002F C++ — manual control",[130],{"type":80,"attrs":131,"content":133},{"id":132},"p_b34ftpyv",[134,138,140,145],{"text":135,"type":75,"marks":136},"You allocate and you free.",[137],{"type":78},{"text":139,"type":75}," Maximum performance, maximum responsibility. Forgot one? ",{"text":141,"type":75,"marks":142},"free()",[143],{"type":144},"code",{"text":146,"type":75},": memory leak. Freed twice: double-free. Accessed after freeing: use-after-free. 70% of Microsoft's vulnerabilities came from here.",{"type":124,"attrs":148,"content":152},{"id":149,"side":150,"title":151},"col_5l89w1q5","neutral","Go — Garbage Collector",[153],{"type":80,"attrs":154,"content":156},{"id":155},"p_957ihscs",[157,161],{"text":158,"type":75,"marks":159},"The runtime decides.",[160],{"type":78},{"text":162,"type":75}," You don't manage memory — the GC scans and frees what is no longer in use. Safe, but with a cost: unpredictable periodic pauses. Discord migrated because the GC caused spikes every 2 minutes.",{"type":124,"attrs":164,"content":168},{"id":165,"side":166,"title":167},"col_z2od7dpm","right","Rust — Ownership",[169],{"type":80,"attrs":170,"content":172},{"id":171},"p_uj02dtq4",[173,177],{"text":174,"type":75,"marks":175},"The compiler decides.",[176],{"type":78},{"text":178,"type":75}," Rules verified at compile time ensure that memory is freed exactly when it should be — no GC, no manual management, no runtime surprises.",{"type":69,"attrs":180,"content":182},{"id":181,"level":36},"h_042afuth",[183],{"text":184,"type":75,"marks":185},"Ownership: every value has an owner",[186],{"type":78},{"type":80,"attrs":188,"content":190},{"id":189},"p_0jbj7wtu",[191],{"text":192,"type":75},"Rust's ownership system has three simple rules. All of the language's memory safety derives from them.",{"type":194,"attrs":195},"speedCards",{"id":196,"cards":197,"title":9,"caption":9},"speed_4typc078",[198,202,206],{"label":199,"value":200,"detail":201},"Each value has exactly one owner","1","Uma variável é a dona do valor que ela armazena. Não existe valor sem dono.",{"label":203,"value":204,"detail":205},"There can only be one owner at a time","2","Quando você atribui um valor a outra variável, a propriedade se transfere — a variável original deixa de ser válida.",{"label":207,"value":208,"detail":209}," When the owner goes out of scope, the value is dropped","3","Sem GC, sem free(). O compilador insere a liberação automaticamente quando a variável deixa de existir.",{"type":80,"attrs":211,"content":213},{"id":212},"p_c6xv0jdu",[214],{"text":215,"type":75},"In practice, it looks like this:",{"type":217,"attrs":218,"content":221},"codeBlock",{"id":219,"language":9,"highlighted":220},"code_8efuprsn","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s1 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> String::\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">from\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"blueprint\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s2 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s1; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ownership se transfere pra s2\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"{}\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, s1); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ❌ erro de compilação: s1 não é mais válida\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"{}\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, s2); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ✅ s2 é a nova dona\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[222],{"text":223,"type":75},"let s1 = String::from(\"blueprint\");\nlet s2 = s1; \u002F\u002F ownership se transfere pra s2\n\nprintln!(\"{}\", s1); \u002F\u002F ❌ erro de compilação: s1 não é mais válida\nprintln!(\"{}\", s2); \u002F\u002F ✅ s2 é a nova dona",{"type":80,"attrs":225,"content":227},{"id":226},"p_0znpmnjv",[228],{"text":229,"type":75},"In C or Go, this code would work — and you would have two pointers pointing to the same data in memory. In Rust, the compiler refuses it immediately. There is no chance of a double-free or accidental use of a value that has already been moved.",{"type":94,"attrs":231,"content":234},{"id":232,"type":233,"title":9},"call_u0egoclx","info",[235],{"type":80,"attrs":236,"content":238},{"id":237},"p_jszzmntd",[239,243,245,249,251,255],{"text":240,"type":75,"marks":241},"Why String and not &str?",[242],{"type":78},{"text":244,"type":75}," Types that live on the stack (like integers) are copied automatically — they are cheap enough. Types that live on the heap (like ",{"text":246,"type":75,"marks":247},"String",[248],{"type":144},{"text":250,"type":75},") transfer ownership. If you want to copy a String, you need to call ",{"text":252,"type":75,"marks":253},".clone()",[254],{"type":144},{"text":256,"type":75}," explicitly — which makes the cost of the operation visible in the code.",{"type":69,"attrs":258,"content":260},{"id":259,"level":36},"h_jbj7qepm",[261],{"text":262,"type":75,"marks":263},"Borrowing: using without being the owner",[264],{"type":78},{"type":80,"attrs":266,"content":268},{"id":267},"p_cx73rssf",[269],{"text":270,"type":75},"If ownership were the only way to access data, you would have to transfer ownership every time you passed something to a function — and receive it back later. Infeasible.",{"type":272,"attrs":273},"svgDiagram",{"id":274,"svg":275,"label":276},"svg_r5lkwmey","\u003Csvg viewBox=\"0 0 471 405\" xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" font-family=\"system-ui, -apple-system, sans-serif\">\n\u003Cdefs>\u003Cmarker id=\"dgArrow\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">\u003Cpath d=\"M 0 1 L 9 5 L 0 9 z\" fill=\"#64748b\"\u002F>\u003C\u002Fmarker>\u003C\u002Fdefs>\n\u003Crect x=\"0\" y=\"0\" width=\"471\" height=\"405\" fill=\"#ffffff\" rx=\"0\"\u002F>\n\u003Ctext x=\"235.5\" y=\"36\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"16\" font-weight=\"700\" fill=\"#0f172a\">Ownership Transfer vs Borrowing in Rust\u003C\u002Ftext>\n\u003Cpath d=\"M 235.046875 143 C 235.046875 171, 133.28125 171, 133.28125 199\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#dgArrow)\"\u002F>\n\u003Ctext x=\"184.1640625\" y=\"171\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"11\" fill=\"#475569\" paint-order=\"stroke\" stroke=\"#ffffff\" stroke-width=\"4\" stroke-linejoin=\"round\">Ownership transfer\u003C\u002Ftext>\n\u003Cpath d=\"M 235.046875 143 C 235.046875 171, 358.3359375 171, 358.3359375 199\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#dgArrow)\"\u002F>\n\u003Ctext x=\"296.69140625\" y=\"171\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"11\" fill=\"#475569\" paint-order=\"stroke\" stroke=\"#ffffff\" stroke-width=\"4\" stroke-linejoin=\"round\">Borrowing (reference)\u003C\u002Ftext>\n\u003Cpath d=\"M 358.3359375 262 C 358.3359375 290, 235.0546875 290, 235.0546875 318\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#dgArrow)\"\u002F>\n\u003Ctext x=\"296.6953125\" y=\"290\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"11\" fill=\"#475569\" paint-order=\"stroke\" stroke=\"#ffffff\" stroke-width=\"4\" stroke-linejoin=\"round\">Pass reference\u003C\u002Ftext>\n\u003Crect x=\"141.125\" y=\"80\" width=\"187.84375\" height=\"63\" rx=\"10\" fill=\"#ffffff\" stroke=\"#94a3b8\" stroke-width=\"1.5\"\u002F>\n\u003Ctext x=\"235.046875\" y=\"101.5\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"14\" font-weight=\"600\" fill=\"#1e293b\">Variable A: owns String\u003C\u002Ftext>\n\u003Ctext x=\"235.046875\" y=\"123\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"12\" font-weight=\"400\" fill=\"#64748b\">Owns the heap data\u003C\u002Ftext>\n\u003Crect x=\"24\" y=\"199\" width=\"218.5625\" height=\"63\" rx=\"10\" fill=\"#ffffff\" stroke=\"#94a3b8\" stroke-width=\"1.5\"\u002F>\n\u003Ctext x=\"133.28125\" y=\"220.5\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"14\" font-weight=\"600\" fill=\"#1e293b\">Variable B: takes ownership\u003C\u002Ftext>\n\u003Ctext x=\"133.28125\" y=\"242\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"12\" font-weight=\"400\" fill=\"#64748b\">Ownership transferred from A\u003C\u002Ftext>\n\u003Crect x=\"270.5625\" y=\"199\" width=\"175.546875\" height=\"63\" rx=\"10\" fill=\"#ffffff\" stroke=\"#94a3b8\" stroke-width=\"1.5\"\u002F>\n\u003Ctext x=\"358.3359375\" y=\"220.5\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"14\" font-weight=\"600\" fill=\"#1e293b\">Reference to String\u003C\u002Ftext>\n\u003Ctext x=\"358.3359375\" y=\"242\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"12\" font-weight=\"400\" fill=\"#64748b\">Borrowed from Variable A\u003C\u002Ftext>\n\u003Crect x=\"123.34375\" y=\"318\" width=\"223.421875\" height=\"63\" rx=\"10\" fill=\"#ffffff\" stroke=\"#94a3b8\" stroke-width=\"1.5\"\u002F>\n\u003Ctext x=\"235.0546875\" y=\"339.5\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"14\" font-weight=\"600\" fill=\"#1e293b\">Function receiving &amp;String\u003C\u002Ftext>\n\u003Ctext x=\"235.0546875\" y=\"361\" text-anchor=\"middle\" dominant-baseline=\"central\" font-size=\"12\" font-weight=\"400\" fill=\"#64748b\">Uses reference without ownership\u003C\u002Ftext>\n\u003C\u002Fsvg>","Ownership Transfer vs Borrowing in Rust",{"type":80,"attrs":278,"content":280},{"id":279},"p_je48osmd",[281,283,287],{"text":282,"type":75},"That is where ",{"text":284,"type":75,"marks":285},"borrowing",[286],{"type":78},{"text":288,"type":75}," comes in: you lend a reference to the value without transferring ownership.",{"type":217,"attrs":290,"content":293},{"id":291,"language":9,"highlighted":292},"code_a5ek8yzm","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">fn \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">tamanho\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(s: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">String) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">->\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> usize { \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F recebe uma referência, não o valor\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    s.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">()\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> minha_string \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> String::\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">from\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"blueprint\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> tam \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> tamanho\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">minha_string); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F passa a referência\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"{} tem {} caracteres\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, minha_string, tam);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ✅ minha_string ainda é válida — ownership não foi transferida\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[294],{"text":295,"type":75},"fn tamanho(s: &String) -> usize { \u002F\u002F recebe uma referência, não o valor\n    s.len()\n}\n\nlet minha_string = String::from(\"blueprint\");\nlet tam = tamanho(&minha_string); \u002F\u002F passa a referência\n\nprintln!(\"{} tem {} caracteres\", minha_string, tam);\n\u002F\u002F ✅ minha_string ainda é válida — ownership não foi transferida",{"type":69,"attrs":297,"content":300},{"id":298,"level":299},"h_rc53zm15",3,[301],{"text":302,"type":75,"marks":303},"Mutable references — and the most important rule of borrowing",[304],{"type":78},{"type":80,"attrs":306,"content":308},{"id":307},"p_s9qd9p40",[309],{"text":310,"type":75},"You can lend mutability too — but with a crucial restriction:",{"type":217,"attrs":312,"content":315},{"id":313,"language":9,"highlighted":314},"code_fiynsk7o","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> mut s \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> String::\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">from\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"blueprint\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> r1 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> &#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">mut s;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> r2 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> &#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">mut s; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ❌ erro: não pode ter duas referências mutáveis ao mesmo tempo\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[316],{"text":317,"type":75},"let mut s = String::from(\"blueprint\");\n\nlet r1 = &mut s;\nlet r2 = &mut s; \u002F\u002F ❌ erro: não pode ter duas referências mutáveis ao mesmo tempo",{"type":217,"attrs":319,"content":322},{"id":320,"language":9,"highlighted":321},"code_or6f44t3","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> mut s \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> String::\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">from\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"blueprint\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">{\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> r1 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> &#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">mut s;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    r1.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">push_str\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\" blog\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">} \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F r1 sai de escopo aqui\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> r2 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> &#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">mut s; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ✅ agora pode — r1 já não existe\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[323],{"text":324,"type":75},"let mut s = String::from(\"blueprint\");\n\n{\n    let r1 = &mut s;\n    r1.push_str(\" blog\");\n} \u002F\u002F r1 sai de escopo aqui\n\nlet r2 = &mut s; \u002F\u002F ✅ agora pode — r1 já não existe\n",{"type":80,"attrs":326,"content":328},{"id":327},"p_bahdaf96",[329],{"text":330,"type":75},"This rule eliminates data races at compile time. In Go or C, two threads being able to write to the same data at the same time is a ticking time bomb. In Rust, the compiler simply doesn't let this happen.",{"type":94,"attrs":332,"content":335},{"id":333,"type":97,"title":334},"call_598vehyc","Borrowing rules prevent data races at compile time",[336,342,348],{"type":80,"attrs":337,"content":339},{"id":338},"p_59mjfwsx",[340],{"text":341,"type":75},"Rust enforces that you can have multiple immutable references or exactly one mutable reference to data at a time, never both simultaneously. This strict rule ensures that data races cannot occur during concurrent access.",{"type":80,"attrs":343,"content":345},{"id":344},"p_t5pt333u",[346],{"text":347,"type":75},"Unlike languages like Go or C, where simultaneous writes by multiple threads can cause unpredictable bugs, Rust's compiler prevents such scenarios before the program even runs.",{"type":80,"attrs":349,"content":351},{"id":350},"p_a579fhrc",[352],{"text":353,"type":75},"This compile-time guarantee is a key advantage of Rust, eliminating an entire class of concurrency errors by design.",{"type":94,"attrs":355,"content":358},{"id":356,"type":357,"title":9},"call_wtkl13u4","tip",[359],{"type":80,"attrs":360,"content":362},{"id":361},"p_knmzmnrj",[363,367,369,373],{"text":364,"type":75,"marks":365},"The complete borrowing rule:",[366],{"type":78},{"text":368,"type":75}," you can have any number of immutable references ",{"text":370,"type":75,"marks":371},"or",[372],{"type":90},{"text":374,"type":75}," exactly one mutable reference — never both at the same time. This is enough to eliminate an entire category of concurrency bugs.",{"type":69,"attrs":376,"content":378},{"id":377,"level":36},"h_d2kv46fh",[379],{"text":380,"type":75,"marks":381},"Lifetimes: when the compiler needs help",[382],{"type":78},{"type":80,"attrs":384,"content":386},{"id":385},"p_0a08fowy",[387,389,393],{"text":388,"type":75},"The Rust compiler can infer most ownership and borrowing situations automatically. But there is one case where it needs an explicit hint: when a function returns a reference, and the compiler needs to know ",{"text":390,"type":75,"marks":391},"which of the parameters",[392],{"type":90},{"text":394,"type":75}," it comes from.",{"type":217,"attrs":396,"content":399},{"id":397,"language":9,"highlighted":398},"code_949mt175","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F Sem lifetime — o compilador não sabe de onde vem a referência retornada\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">fn \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">maior\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(x: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">str, y: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">str) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">->\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> &#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">str { \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ❌ erro de compilação\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> x.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">() \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> y.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">() { x } \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { y }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[400],{"text":401,"type":75},"\u002F\u002F Sem lifetime — o compilador não sabe de onde vem a referência retornada\nfn maior(x: &str, y: &str) -> &str { \u002F\u002F ❌ erro de compilação\n    if x.len() > y.len() { x } else { y }\n}",{"type":217,"attrs":403,"content":406},{"id":404,"language":9,"highlighted":405},"code_ge4t0bqz","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F Com lifetime — o compilador sabe que o retorno vive tanto quanto x e y\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">fn maior\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'a>(x: &#x26;'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">a str, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">y\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">'a str) -> &#x26;'\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">a str { \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ✅\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> x.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">() \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> y.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">() { x } \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> { y }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[407],{"text":408,"type":75},"\u002F\u002F Com lifetime — o compilador sabe que o retorno vive tanto quanto x e y\nfn maior\u003C'a>(x: &'a str, y: &'a str) -> &'a str { \u002F\u002F ✅\n    if x.len() > y.len() { x } else { y }\n}",{"type":80,"attrs":410,"content":412},{"id":411},"p_7s0by5u8",[413,415,419,421,425],{"text":414,"type":75},"The ",{"text":416,"type":75,"marks":417},"'a",[418],{"type":144},{"text":420,"type":75}," is a lifetime annotation. It doesn't create anything — it just tells the compiler: ",{"text":422,"type":75,"marks":423},"\"the returned reference lives for the same amount of time as both parameters.\"",[424],{"type":90},{"text":426,"type":75}," With this information, it can verify that you will never return a reference to something that has already been freed.",{"type":94,"attrs":428,"content":431},{"id":429,"type":430,"title":9},"call_n8e8kn20","warning",[432],{"type":80,"attrs":433,"content":435},{"id":434},"p_zf69cboy",[436,440,442,446],{"text":437,"type":75,"marks":438},"Lifetimes are the biggest friction point in Rust.",[439],{"type":78},{"text":441,"type":75}," The good news: the compiler needed explicit annotations in much simpler cases in the past. Modern versions of Rust infer lifetimes in most cases with the ",{"text":443,"type":75,"marks":444},"lifetime elision rules",[445],{"type":90},{"text":447,"type":75}," — you only need to annotate when the situation is genuinely ambiguous.",{"type":69,"attrs":449,"content":451},{"id":450,"level":36},"h_cz3dlaqk",[452],{"text":453,"type":75,"marks":454},"Comparing in practice: the same bug in three languages",[455],{"type":78},{"type":80,"attrs":457,"content":459},{"id":458},"p_kcugwo5z",[460],{"text":461,"type":75},"Use-after-free is one of the most common and dangerous vulnerabilities. See how each language handles it:",{"type":119,"attrs":463,"content":465},{"id":464},"cmp_hyru17uo",[466,501],{"type":124,"attrs":467,"content":470},{"id":468,"side":127,"title":469},"col_it93qvzy","C: Undefined Behavior",[471,477,483,489,495],{"type":80,"attrs":472,"content":474},{"id":473},"p_vc7pq6ol",[475],{"text":476,"type":75},"Memory is manually allocated and freed.",{"type":80,"attrs":478,"content":480},{"id":479},"p_z9eg51da",[481],{"text":482,"type":75},"Use-after-free occurs when accessing freed memory.",{"type":80,"attrs":484,"content":486},{"id":485},"p_cssrrqbe",[487],{"text":488,"type":75},"Compiler does not catch the error.",{"type":80,"attrs":490,"content":492},{"id":491},"p_h8ds1r7v",[493],{"text":494,"type":75},"Program compiles and runs but behavior is unpredictable.",{"type":80,"attrs":496,"content":498},{"id":497},"p_e1bptaqp",[499],{"text":500,"type":75},"Leads to potential security vulnerabilities.",{"type":124,"attrs":502,"content":505},{"id":503,"side":166,"title":504},"col_vylom8p3","Go: Runtime GC Prevention",[506,512,518,524,530],{"type":80,"attrs":507,"content":509},{"id":508},"p_n0pwulne",[510],{"text":511,"type":75},"Garbage collector manages memory automatically.",{"type":80,"attrs":513,"content":515},{"id":514},"p_uov9s5ft",[516],{"text":517,"type":75},"Prevents premature freeing of memory.",{"type":80,"attrs":519,"content":521},{"id":520},"p_mvbu1acs",[522],{"text":523,"type":75},"Use-after-free is avoided at runtime.",{"type":80,"attrs":525,"content":527},{"id":526},"p_9bqu9f9v",[528],{"text":529,"type":75},"No compile-time errors related to memory use.",{"type":80,"attrs":531,"content":533},{"id":532},"p_5gxwm28z",[534],{"text":535,"type":75},"Adds runtime overhead due to GC management.",{"type":217,"attrs":537,"content":540},{"id":538,"language":9,"highlighted":539},"code_9dz9exci","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F* C — compila, executa, comportamento indefinido *\u002F\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">char \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">*\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">s \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> malloc\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">10\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">free\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(s);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"%s\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, s); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F acessa memória liberada — undefined behavior\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[541],{"text":542,"type":75},"\u002F* C — compila, executa, comportamento indefinido *\u002F\nchar *s = malloc(10);\nfree(s);\nprintf(\"%s\", s); \u002F\u002F acessa memória liberada — undefined behavior",{"type":217,"attrs":544,"content":547},{"id":545,"language":9,"highlighted":546},"code_zjku02sm","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F Go — GC previne liberação prematura, mas com custo em runtime\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F O GC garante que s não será liberada enquanto ainda houver referências\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">s\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> :\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"blueprint\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">fmt.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">Println\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(s) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F sempre seguro, mas o GC adiciona overhead\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[548],{"text":549,"type":75},"\u002F\u002F Go — GC previne liberação prematura, mas com custo em runtime\n\u002F\u002F O GC garante que s não será liberada enquanto ainda houver referências\ns := \"blueprint\"\nfmt.Println(s) \u002F\u002F sempre seguro, mas o GC adiciona overhead",{"type":217,"attrs":551,"content":554},{"id":552,"language":9,"highlighted":553},"code_u8fx75ia","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F Rust — erro em tempo de compilação, zero custo em runtime\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">let\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> s \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> String::\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">from\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"blueprint\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">drop\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(s); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F libera explicitamente\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">println\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">!\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"{}\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, s); \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F ❌ erro de compilação — o compilador recusa\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F esse código nunca chega em produção\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[555],{"text":556,"type":75},"\u002F\u002F Rust — erro em tempo de compilação, zero custo em runtime\nlet s = String::from(\"blueprint\");\ndrop(s); \u002F\u002F libera explicitamente\nprintln!(\"{}\", s); \u002F\u002F ❌ erro de compilação — o compilador recusa\n\u002F\u002F esse código nunca chega em produção",{"type":80,"attrs":558,"content":560},{"id":559},"p_63wieaj0",[561,563,567],{"text":562,"type":75},"This is the fundamental difference: C discovers the problem in production (when it has already caused damage). Go prevents it at runtime with a GC (but pays the latency cost). Rust prevents it at compile time — ",{"text":564,"type":75,"marks":565},"at zero runtime cost",[566],{"type":78},{"text":568,"type":75},".",{"type":570,"attrs":571},"summaryBox",{"id":572,"items":573,"title":580},"sum_vskcmddd",[574,575,576,577,578,579],"Ownership — each value has an owner. When the owner goes out of scope, the memory is freed automatically.","Move semantics — transferring a value invalidates the original variable. Double-free is impossible.","Borrowing — referencing without transferring. Immutable: as many as you want. Mutable: only one at a time.","No data race — two simultaneous mutable references will not compile. Safe concurrency by design.","Lifetimes — the compiler verifies that no reference outlives the value it points to. Dangling pointers are impossible.","Zero runtime cost — all of this is verified at compile time. In production, the binary is as fast as C.","What the compiler guarantees for you",{"type":80,"attrs":582},{"id":583},"p_zlxqztpq","Memory Management in Rust: Ownership, Borrowing & Lifetimes","Master Rust's memory management. Learn how ownership, borrowing, and lifetimes ensure memory safety and zero-cost performance at compile time.","2026-08-24T14:53:53.315534+00:00",[588,613,633,647],{"id":589,"slug":590,"title":591,"excerpt":592,"image":593,"featured":594,"groupId":595,"publishedAt":596,"readingTime":597,"views":48,"author":598,"category":599,"tags":600},"81f24e9a-fc6b-47d0-beb9-d00a6137ed99","framework-vs-sdk-who-calls-whom","Framework vs SDK: Who Calls Whom","Most developers memorize names, but few understand the mechanism. Here is the simple rule to tell a framework from an SDK and level up your debugging.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1787491947099-featured-ikba2e.jpg",true,"0ccb21eb-6459-40ed-8110-227836e9bb74","2026-08-23T13:15:25.439194+00:00",10,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[601,604,607,610],{"slug":602,"name":603},"javascript","JavaScript",{"slug":605,"name":606},"python","Python",{"slug":608,"name":609},"runtime","Runtime",{"slug":611,"name":612},"sdk","Sdk",{"id":614,"slug":615,"title":616,"excerpt":617,"image":618,"featured":44,"groupId":619,"publishedAt":620,"readingTime":621,"views":622,"author":623,"category":624,"tags":625},"c2d6b1ca-29bf-401f-8ab9-a1f828504d0b","microfrontends-with-angular-and-nx-what-nobody-tells-you","Microfrontends with Angular and Nx: what nobody tells you","Every tutorial teaches how to set up microfrontends in minutes, but few reveal the architectural chaos that emerges after months of production deploys.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1785206853570-featured-zoyhgn.webp","3368e1b2-b6de-4e94-a3d4-294fae8ade13","2026-08-03T01:42:48.969355+00:00",15,5,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[626,629,630],{"slug":627,"name":628},"angular","Angular",{"slug":602,"name":603},{"slug":631,"name":632},"typescript","TypeScript",{"id":634,"slug":635,"title":636,"excerpt":637,"image":638,"featured":44,"groupId":639,"publishedAt":640,"readingTime":641,"views":597,"author":642,"category":643,"tags":644},"36440333-311c-4081-92e6-030a04a38fed","astro-island-architecture-performance-and-where-the-framework-truly-fits","Astro: Island Architecture, Performance, and Where the Framework Truly Fits","Astro challenges the modern web status quo by prioritizing static HTML and isolating interactivity into independent, lightweight code islands.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1785721161920-featured-a5vzkb.webp","cb62459e-7ace-43d3-a545-661c5695e925","2026-08-03T01:00:45.280114+00:00",38,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[645,646],{"slug":602,"name":603},{"slug":631,"name":632},{"id":648,"slug":649,"title":650,"excerpt":651,"image":652,"featured":44,"groupId":653,"publishedAt":654,"readingTime":655,"views":48,"author":656,"category":657,"tags":658},"633b6488-2a90-4632-86a5-9cff7ed52f08","javascript-event-loop-the-heart-of-non-blocking-concurrency-revisited-in-2025","JavaScript Event Loop: The Heart of Non-Blocking Concurrency — Revisited in 2025","The Event Loop is not just a simple loop, but a sophisticated coordination mechanism between Call Stack, queues, and runtime. Essential for JS concurrency, it enables thousands of asynchronous operations without blocking the UI. This guide explores its structure, differences between Node.js and browsers, common bugs, advanced techniques, and 2025 trends like Structured Concurrency and scheduler.yield().","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1772847201637-featured-oreiro.jpeg","df6ca967-8130-4b2d-bcac-3532a150131e","2026-07-26T18:54:25.359533+00:00",6,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[659,660],{"slug":602,"name":603},{"slug":661,"name":662},"nodejs","Node.js",{"en":40,"pt":664},"gerenciamento-de-memoria-no-rust-ownership-borrowing-e-lifetimes-sem-misterio"]