[{"data":1,"prerenderedAt":1220},["ShallowReactive",2],{"page-\u002Frust\u002F07-ownership":3},{"id":4,"title":5,"body":6,"description":1213,"extension":1214,"meta":1215,"navigation":329,"path":1216,"seo":1217,"stem":1218,"__hash__":1219},"content\u002Frust\u002F07-ownership.md","07 — Ownership (The Heart of Rust)",{"type":7,"value":8,"toc":1190},"minimark",[9,13,22,27,57,61,85,163,176,183,189,216,232,286,290,368,374,413,417,471,474,478,485,550,564,573,588,592,707,710,714,776,783,790,883,886,895,906,910,913,933,940,1009,1029,1038,1143,1146,1150,1178,1186],[10,11,5],"h1",{"id":12},"_07-ownership-the-heart-of-rust",[14,15,16,17,21],"p",{},"Ownership is ",[18,19,20],"strong",{},"the"," defining feature of Rust. Every other memory-safety guarantee flows from these rules.",[23,24,26],"h2",{"id":25},"the-three-rules","The Three Rules",[28,29,30,38,45],"ol",{},[31,32,33,34,37],"li",{},"Each value has exactly one ",[18,35,36],{},"owner"," (a variable).",[31,39,40,41,44],{},"When the owner goes out of scope, the value is ",[18,42,43],{},"dropped"," (its destructor runs).",[31,46,47,48,51,52,56],{},"Assigning or passing a value ",[18,49,50],{},"moves"," it (for non-",[53,54,55],"code",{},"Copy"," types) — the old binding becomes invalid.",[23,58,60],{"id":59},"stack-vs-heap","Stack vs Heap",[62,63,64,71],"ul",{},[31,65,66,67,70],{},"Stack: fast, LIFO, fixed-size values (integers, ",[53,68,69],{},"bool",", fixed arrays, pointers).",[31,72,73,74,77,78,77,81,84],{},"Heap: dynamic, slower, runtime-allocated (",[53,75,76],{},"Box",", ",[53,79,80],{},"Vec",[53,82,83],{},"String","). Ownership primarily concerns heap data.",[86,87,90],"code-wrapper",{"language":88,"filename":89},"rust","main.rs",[91,92,96],"pre",{"className":93,"code":94,"language":88,"meta":95,"style":95},"language-rust shiki shiki-themes github-light github-dark","let s1 = String::from(\"hi\");   \u002F\u002F heap allocation\nlet s2 = s1;                    \u002F\u002F MOVE — s1 is now invalid\n\u002F\u002F println!(\"{s1}\");            \u002F\u002F ERROR: borrow of moved value\n","",[53,97,98,138,154],{"__ignoreMap":95},[99,100,103,107,111,114,118,121,124,127,131,134],"span",{"class":101,"line":102},"line",1,[99,104,106],{"class":105},"svdQ7","let",[99,108,110],{"class":109},"ssxIu"," s1 ",[99,112,113],{"class":105},"=",[99,115,117],{"class":116},"sIsaT"," String",[99,119,120],{"class":105},"::",[99,122,123],{"class":116},"from",[99,125,126],{"class":109},"(",[99,128,130],{"class":129},"sJ6F3","\"hi\"",[99,132,133],{"class":109},");   ",[99,135,137],{"class":136},"sdCPZ","\u002F\u002F heap allocation\n",[99,139,141,143,146,148,151],{"class":101,"line":140},2,[99,142,106],{"class":105},[99,144,145],{"class":109}," s2 ",[99,147,113],{"class":105},[99,149,150],{"class":109}," s1;                    ",[99,152,153],{"class":136},"\u002F\u002F MOVE — s1 is now invalid\n",[99,155,157,160],{"class":101,"line":156},3,[99,158,159],{"class":136},"\u002F\u002F println!(\"{s1}\");",[99,161,162],{"class":136},"            \u002F\u002F ERROR: borrow of moved value\n",[14,164,165,167,168,171,172,175],{},[53,166,83],{}," is ",[53,169,170],{},"{ ptr, len, capacity }"," (stack) pointing to heap bytes. A move copies the stack header and ",[18,173,174],{},"invalidates the old binding"," so you can't have two owners trying to free the same heap memory.",[23,177,179,180,182],{"id":178},"the-copy-trait","The ",[53,181,55],{}," Trait",[14,184,185,186,188],{},"Types whose bits can be trivially copied without invalidating the source are ",[53,187,55],{},":",[62,190,191,194,200,209],{},[31,192,193],{},"All integer\u002Ffloat\u002Fbool\u002Fchar types.",[31,195,196,197,199],{},"Tuples\u002Farrays of ",[53,198,55],{}," types.",[31,201,202,205,206,208],{},[53,203,204],{},"&T"," (shared references are ",[53,207,55],{},").",[31,210,211,212,215],{},"Function pointers ",[53,213,214],{},"fn(...)",".",[14,217,218,219,221,222,77,224,77,226,77,228,231],{},"Non-",[53,220,55],{}," types (heap-ish): ",[53,223,83],{},[53,225,80],{},[53,227,76],{},[53,229,230],{},"HashMap",", any type with a destructor or that owns a resource.",[86,233,234],{"language":88},[91,235,237],{"className":93,"code":236,"language":88,"meta":95,"style":95},"let a = 5;\nlet b = a;            \u002F\u002F i32 is Copy — a is still valid\nprintln!(\"{a} {b}\");  \u002F\u002F fine\n",[53,238,239,255,270],{"__ignoreMap":95},[99,240,241,243,246,248,252],{"class":101,"line":102},[99,242,106],{"class":105},[99,244,245],{"class":109}," a ",[99,247,113],{"class":105},[99,249,251],{"class":250},"snvgF"," 5",[99,253,254],{"class":109},";\n",[99,256,257,259,262,264,267],{"class":101,"line":140},[99,258,106],{"class":105},[99,260,261],{"class":109}," b ",[99,263,113],{"class":105},[99,265,266],{"class":109}," a;            ",[99,268,269],{"class":136},"\u002F\u002F i32 is Copy — a is still valid\n",[99,271,272,275,277,280,283],{"class":101,"line":156},[99,273,274],{"class":116},"println!",[99,276,126],{"class":109},[99,278,279],{"class":129},"\"{a} {b}\"",[99,281,282],{"class":109},");  ",[99,284,285],{"class":136},"\u002F\u002F fine\n",[23,287,289],{"id":288},"move-semantics-in-functions","Move Semantics in Functions",[86,291,292],{"language":88},[91,293,295],{"className":93,"code":294,"language":88,"meta":95,"style":95},"fn take(s: String) { println!(\"{s}\"); }\n\nlet s = String::from(\"hi\");\ntake(s);\n\u002F\u002F s is now invalid — moved into the function\n",[53,296,297,325,331,353,362],{"__ignoreMap":95},[99,298,299,302,305,308,310,312,315,317,319,322],{"class":101,"line":102},[99,300,301],{"class":105},"fn",[99,303,304],{"class":116}," take",[99,306,307],{"class":109},"(s",[99,309,188],{"class":105},[99,311,117],{"class":116},[99,313,314],{"class":109},") { ",[99,316,274],{"class":116},[99,318,126],{"class":109},[99,320,321],{"class":129},"\"{s}\"",[99,323,324],{"class":109},"); }\n",[99,326,327],{"class":101,"line":140},[99,328,330],{"emptyLinePlaceholder":329},true,"\n",[99,332,333,335,338,340,342,344,346,348,350],{"class":101,"line":156},[99,334,106],{"class":105},[99,336,337],{"class":109}," s ",[99,339,113],{"class":105},[99,341,117],{"class":116},[99,343,120],{"class":105},[99,345,123],{"class":116},[99,347,126],{"class":109},[99,349,130],{"class":129},[99,351,352],{"class":109},");\n",[99,354,356,359],{"class":101,"line":355},4,[99,357,358],{"class":116},"take",[99,360,361],{"class":109},"(s);\n",[99,363,365],{"class":101,"line":364},5,[99,366,367],{"class":136},"\u002F\u002F s is now invalid — moved into the function\n",[14,369,370,371,188],{},"To keep ownership, pass by reference or ",[53,372,373],{},"clone()",[86,375,376],{"language":88},[91,377,379],{"className":93,"code":378,"language":88,"meta":95,"style":95},"take(s.clone());      \u002F\u002F s still owned here\ntake(&s);             \u002F\u002F pass reference (covered in References chapter)\n",[53,380,381,398],{"__ignoreMap":95},[99,382,383,385,387,389,392,395],{"class":101,"line":102},[99,384,358],{"class":116},[99,386,307],{"class":109},[99,388,215],{"class":105},[99,390,391],{"class":116},"clone",[99,393,394],{"class":109},"());      ",[99,396,397],{"class":136},"\u002F\u002F s still owned here\n",[99,399,400,402,404,407,410],{"class":101,"line":140},[99,401,358],{"class":116},[99,403,126],{"class":109},[99,405,406],{"class":105},"&",[99,408,409],{"class":109},"s);             ",[99,411,412],{"class":136},"\u002F\u002F pass reference (covered in References chapter)\n",[23,414,416],{"id":415},"returning-ownership","Returning Ownership",[86,418,419],{"language":88},[91,420,422],{"className":93,"code":421,"language":88,"meta":95,"style":95},"fn make() -> String { String::from(\"hi\") }\nlet s = make();       \u002F\u002F ownership moves to caller\n",[53,423,424,455],{"__ignoreMap":95},[99,425,426,428,431,434,437,439,442,444,446,448,450,452],{"class":101,"line":102},[99,427,301],{"class":105},[99,429,430],{"class":116}," make",[99,432,433],{"class":109},"() ",[99,435,436],{"class":105},"->",[99,438,117],{"class":116},[99,440,441],{"class":109}," { ",[99,443,83],{"class":116},[99,445,120],{"class":105},[99,447,123],{"class":116},[99,449,126],{"class":109},[99,451,130],{"class":129},[99,453,454],{"class":109},") }\n",[99,456,457,459,461,463,465,468],{"class":101,"line":140},[99,458,106],{"class":105},[99,460,337],{"class":109},[99,462,113],{"class":105},[99,464,430],{"class":116},[99,466,467],{"class":109},"();       ",[99,469,470],{"class":136},"\u002F\u002F ownership moves to caller\n",[14,472,473],{},"Returning transfers ownership out without a copy. This is the Rust idiom for \"constructing\" data.",[23,475,477],{"id":476},"drop-order","Drop Order",[14,479,480,481,484],{},"Destructors run in ",[18,482,483],{},"reverse declaration order"," within a scope:",[86,486,487],{"language":88},[91,488,490],{"className":93,"code":489,"language":88,"meta":95,"style":95},"{\n    let a = String::from(\"a\");\n    let b = String::from(\"b\");\n    \u002F\u002F b drops, then a drops\n}\n",[53,491,492,497,519,540,545],{"__ignoreMap":95},[99,493,494],{"class":101,"line":102},[99,495,496],{"class":109},"{\n",[99,498,499,502,504,506,508,510,512,514,517],{"class":101,"line":140},[99,500,501],{"class":105},"    let",[99,503,245],{"class":109},[99,505,113],{"class":105},[99,507,117],{"class":116},[99,509,120],{"class":105},[99,511,123],{"class":116},[99,513,126],{"class":109},[99,515,516],{"class":129},"\"a\"",[99,518,352],{"class":109},[99,520,521,523,525,527,529,531,533,535,538],{"class":101,"line":156},[99,522,501],{"class":105},[99,524,261],{"class":109},[99,526,113],{"class":105},[99,528,117],{"class":116},[99,530,120],{"class":105},[99,532,123],{"class":116},[99,534,126],{"class":109},[99,536,537],{"class":129},"\"b\"",[99,539,352],{"class":109},[99,541,542],{"class":101,"line":355},[99,543,544],{"class":136},"    \u002F\u002F b drops, then a drops\n",[99,546,547],{"class":101,"line":364},[99,548,549],{"class":109},"}\n",[14,551,552,555,556,559,560,563],{},[53,553,554],{},"Drop"," trait's ",[53,557,558],{},"drop(&mut self)"," is the destructor. You usually don't call it manually — use ",[53,561,562],{},"std::mem::drop(value)"," to drop early.",[23,565,567,569,570,572],{"id":566},"drop-and-copy-are-mutually-exclusive",[53,568,554],{}," and ",[53,571,55],{}," are Mutually Exclusive",[14,574,575,576,578,579,581,582,584,585,587],{},"A type with a custom ",[53,577,554],{}," cannot be ",[53,580,55],{}," (you can't derive both). ",[53,583,55],{}," means \"duplicate bits\"; ",[53,586,554],{}," means \"do something on cleanup\" — duplicating would risk double-cleanup.",[23,589,591],{"id":590},"partial-moves","Partial Moves",[86,593,594],{"language":88},[91,595,597],{"className":93,"code":596,"language":88,"meta":95,"style":95},"struct Person { name: String, age: u32 }\nlet p = Person { name: \"Ada\".into(), age: 36 };\nlet n = p.name;       \u002F\u002F partial move — p.name is moved, p.age still valid\n\u002F\u002F println!(\"{}\", p); \u002F\u002F ERROR: p partially moved\nprintln!(\"{}\", p.age); \u002F\u002F OK — only name was moved\n",[53,598,599,625,659,679,687],{"__ignoreMap":95},[99,600,601,604,607,610,612,614,617,619,622],{"class":101,"line":102},[99,602,603],{"class":105},"struct",[99,605,606],{"class":116}," Person",[99,608,609],{"class":109}," { name",[99,611,188],{"class":105},[99,613,117],{"class":116},[99,615,616],{"class":109},", age",[99,618,188],{"class":105},[99,620,621],{"class":116}," u32",[99,623,624],{"class":109}," }\n",[99,626,627,629,632,634,636,638,640,643,645,648,651,653,656],{"class":101,"line":140},[99,628,106],{"class":105},[99,630,631],{"class":109}," p ",[99,633,113],{"class":105},[99,635,606],{"class":116},[99,637,609],{"class":109},[99,639,188],{"class":105},[99,641,642],{"class":129}," \"Ada\"",[99,644,215],{"class":105},[99,646,647],{"class":116},"into",[99,649,650],{"class":109},"(), age",[99,652,188],{"class":105},[99,654,655],{"class":250}," 36",[99,657,658],{"class":109}," };\n",[99,660,661,663,666,668,671,673,676],{"class":101,"line":156},[99,662,106],{"class":105},[99,664,665],{"class":109}," n ",[99,667,113],{"class":105},[99,669,670],{"class":109}," p",[99,672,215],{"class":105},[99,674,675],{"class":109},"name;       ",[99,677,678],{"class":136},"\u002F\u002F partial move — p.name is moved, p.age still valid\n",[99,680,681,684],{"class":101,"line":355},[99,682,683],{"class":136},"\u002F\u002F println!(\"{}\", p);",[99,685,686],{"class":136}," \u002F\u002F ERROR: p partially moved\n",[99,688,689,691,693,696,699,701,704],{"class":101,"line":364},[99,690,274],{"class":116},[99,692,126],{"class":109},[99,694,695],{"class":129},"\"{}\"",[99,697,698],{"class":109},", p",[99,700,215],{"class":105},[99,702,703],{"class":109},"age); ",[99,705,706],{"class":136},"\u002F\u002F OK — only name was moved\n",[14,708,709],{},"You can still access non-moved fields after a partial move.",[23,711,713],{"id":712},"move-footguns","Move Footguns",[62,715,716,733,748,761],{},[31,717,718,721,722,725,726,729,730,732],{},[18,719,720],{},"Closure captures",": ",[53,723,724],{},"|| use_s(s)"," moves ",[53,727,728],{},"s"," into the closure if ",[53,731,728],{}," is consumed inside.",[31,734,735,747],{},[18,736,737,739,740,742,743,746],{},[53,738,80],{},"\u002F",[53,741,83],{}," in ",[53,744,745],{},"match"," arms",": moving a value out in one arm invalidates it in others; the compiler ensures all paths move or none do.",[31,749,750,753,754,757,758,760],{},[18,751,752],{},"Field reorder \u002F re-init",": after a partial move, you can reassign the moved field (",[53,755,756],{},"p.name = \"Bob\".into();",") to make ",[53,759,14],{}," whole again.",[31,762,763,721,769,772,773,775],{},[18,764,765,768],{},[53,766,767],{},"mut"," binding of a moved value",[53,770,771],{},"let mut s = String::new(); let t = s; s = String::from(\"x\");"," — re-binding is fine; ",[53,774,728],{}," was invalid between the move and reassignment.",[23,777,779,782],{"id":778},"drop-order-in-structs",[53,780,781],{},"drop"," Order in Structs",[14,784,785,786,789],{},"Struct fields drop in ",[18,787,788],{},"declaration order"," (NOT reverse), per RFC 1857. This is a common surprise:",[86,791,792],{"language":88},[91,793,795],{"className":93,"code":794,"language":88,"meta":95,"style":95},"struct A { \u002F* ... *\u002F }\nimpl Drop for A { fn drop(&mut self) { println!(\"A dropped\"); } }\n\nstruct Pair { first: A, second: A }\n\u002F\u002F when a Pair is dropped: first drops, then second\n",[53,796,797,811,851,855,878],{"__ignoreMap":95},[99,798,799,801,804,806,809],{"class":101,"line":102},[99,800,603],{"class":105},[99,802,803],{"class":116}," A",[99,805,441],{"class":109},[99,807,808],{"class":136},"\u002F* ... *\u002F",[99,810,624],{"class":109},[99,812,813,816,819,822,824,826,828,831,833,836,839,841,843,845,848],{"class":101,"line":140},[99,814,815],{"class":105},"impl",[99,817,818],{"class":116}," Drop",[99,820,821],{"class":105}," for",[99,823,803],{"class":116},[99,825,441],{"class":109},[99,827,301],{"class":105},[99,829,830],{"class":116}," drop",[99,832,126],{"class":109},[99,834,835],{"class":105},"&mut",[99,837,838],{"class":250}," self",[99,840,314],{"class":109},[99,842,274],{"class":116},[99,844,126],{"class":109},[99,846,847],{"class":129},"\"A dropped\"",[99,849,850],{"class":109},"); } }\n",[99,852,853],{"class":101,"line":156},[99,854,330],{"emptyLinePlaceholder":329},[99,856,857,859,862,865,867,869,872,874,876],{"class":101,"line":355},[99,858,603],{"class":105},[99,860,861],{"class":116}," Pair",[99,863,864],{"class":109}," { first",[99,866,188],{"class":105},[99,868,803],{"class":116},[99,870,871],{"class":109},", second",[99,873,188],{"class":105},[99,875,803],{"class":116},[99,877,624],{"class":109},[99,879,880],{"class":101,"line":364},[99,881,882],{"class":136},"\u002F\u002F when a Pair is dropped: first drops, then second\n",[14,884,885],{},"Tuple fields drop in order 0, 1, 2, ...",[23,887,889,569,892],{"id":888},"manuallydrop-and-maybeuninit",[53,890,891],{},"ManuallyDrop",[53,893,894],{},"MaybeUninit",[14,896,897,898,901,902,905],{},"For unsafe manual memory management, use ",[53,899,900],{},"std::mem::ManuallyDrop"," to prevent auto-drop, or ",[53,903,904],{},"std::mem::MaybeUninit"," for uninitialized memory. These are advanced; covered in the Unsafe chapter.",[23,907,909],{"id":908},"why-ownership-is-unique","Why Ownership Is Unique",[14,911,912],{},"Languages choose between:",[62,914,915,921,927],{},[31,916,917,920],{},[18,918,919],{},"GC"," (Java, Go, Python): runtime cost, pause times.",[31,922,923,926],{},[18,924,925],{},"Manual management"," (C, C++): use-after-free, double-free, leaks.",[31,928,929,932],{},[18,930,931],{},"Ownership"," (Rust): compile-time rules, zero runtime cost, but you learn the borrow checker.",[23,934,936,937],{"id":935},"common-error-cannot-move-out-of","Common Error: ",[53,938,939],{},"cannot move out of ...",[86,941,942],{"language":88},[91,943,945],{"className":93,"code":944,"language":88,"meta":95,"style":95},"let v = vec![String::from(\"a\"), String::from(\"b\")];\nlet first = v[0];   \u002F\u002F ERROR: cannot move out of index of Vec\n",[53,946,947,988],{"__ignoreMap":95},[99,948,949,951,954,956,959,962,964,966,968,970,972,975,977,979,981,983,985],{"class":101,"line":102},[99,950,106],{"class":105},[99,952,953],{"class":109}," v ",[99,955,113],{"class":105},[99,957,958],{"class":116}," vec!",[99,960,961],{"class":109},"[",[99,963,83],{"class":116},[99,965,120],{"class":105},[99,967,123],{"class":116},[99,969,126],{"class":109},[99,971,516],{"class":129},[99,973,974],{"class":109},"), ",[99,976,83],{"class":116},[99,978,120],{"class":105},[99,980,123],{"class":116},[99,982,126],{"class":109},[99,984,537],{"class":129},[99,986,987],{"class":109},")];\n",[99,989,990,992,995,997,1000,1003,1006],{"class":101,"line":140},[99,991,106],{"class":105},[99,993,994],{"class":109}," first ",[99,996,113],{"class":105},[99,998,999],{"class":109}," v[",[99,1001,1002],{"class":250},"0",[99,1004,1005],{"class":109},"];   ",[99,1007,1008],{"class":136},"\u002F\u002F ERROR: cannot move out of index of Vec\n",[14,1010,1011,1012,1015,1016,1018,1019,1022,1023,1022,1026,215],{},"Indexing returns a reference (",[53,1013,1014],{},"&String","); moving out would leave the ",[53,1017,80],{}," in an invalid state. Use ",[53,1020,1021],{},"v.into_iter().next()"," or ",[53,1024,1025],{},"mem::take(&mut v[0])",[53,1027,1028],{},"v.remove(0)",[23,1030,1032,569,1035],{"id":1031},"memtake-and-memreplace",[53,1033,1034],{},"mem::take",[53,1036,1037],{},"mem::replace",[86,1039,1040],{"language":88},[91,1041,1043],{"className":93,"code":1042,"language":88,"meta":95,"style":95},"use std::mem;\nlet mut s = String::from(\"hi\");\nlet taken = mem::take(&mut s);  \u002F\u002F s becomes default (empty String), taken gets \"hi\"\nlet prev = mem::replace(&mut s, \"bye\".into());  \u002F\u002F s = \"bye\", prev = \"\"\n",[53,1044,1045,1058,1081,1107],{"__ignoreMap":95},[99,1046,1047,1050,1053,1055],{"class":101,"line":102},[99,1048,1049],{"class":105},"use",[99,1051,1052],{"class":116}," std",[99,1054,120],{"class":105},[99,1056,1057],{"class":109},"mem;\n",[99,1059,1060,1062,1065,1067,1069,1071,1073,1075,1077,1079],{"class":101,"line":140},[99,1061,106],{"class":105},[99,1063,1064],{"class":105}," mut",[99,1066,337],{"class":109},[99,1068,113],{"class":105},[99,1070,117],{"class":116},[99,1072,120],{"class":105},[99,1074,123],{"class":116},[99,1076,126],{"class":109},[99,1078,130],{"class":129},[99,1080,352],{"class":109},[99,1082,1083,1085,1088,1090,1093,1095,1097,1099,1101,1104],{"class":101,"line":156},[99,1084,106],{"class":105},[99,1086,1087],{"class":109}," taken ",[99,1089,113],{"class":105},[99,1091,1092],{"class":116}," mem",[99,1094,120],{"class":105},[99,1096,358],{"class":116},[99,1098,126],{"class":109},[99,1100,835],{"class":105},[99,1102,1103],{"class":109}," s);  ",[99,1105,1106],{"class":136},"\u002F\u002F s becomes default (empty String), taken gets \"hi\"\n",[99,1108,1109,1111,1114,1116,1118,1120,1123,1125,1127,1130,1133,1135,1137,1140],{"class":101,"line":355},[99,1110,106],{"class":105},[99,1112,1113],{"class":109}," prev ",[99,1115,113],{"class":105},[99,1117,1092],{"class":116},[99,1119,120],{"class":105},[99,1121,1122],{"class":116},"replace",[99,1124,126],{"class":109},[99,1126,835],{"class":105},[99,1128,1129],{"class":109}," s, ",[99,1131,1132],{"class":129},"\"bye\"",[99,1134,215],{"class":105},[99,1136,647],{"class":116},[99,1138,1139],{"class":109},"());  ",[99,1141,1142],{"class":136},"\u002F\u002F s = \"bye\", prev = \"\"\n",[14,1144,1145],{},"These let you extract values from behind a mutable reference without invalidating the container.",[23,1147,1149],{"id":1148},"summary","Summary",[62,1151,1152,1155,1163,1170],{},[31,1153,1154],{},"Each value has one owner; scope-end drops it.",[31,1156,218,1157,1159,1160,1162],{},[53,1158,55],{}," types move on assignment\u002Fpass; ",[53,1161,55],{}," types duplicate.",[31,1164,1165,1167,1168,215],{},[53,1166,554],{}," is a destructor; can't be combined with ",[53,1169,55],{},[31,1171,1172,1173,77,1175,1177],{},"Partial moves, ",[53,1174,1034],{},[53,1176,1037],{}," let you surgically move things around.",[14,1179,1180,1181,1185],{},"Next: References and Borrowing — ",[1182,1183,1184],"em",{},"using"," a value without owning it.",[1187,1188,1189],"style",{},"html pre.shiki code .svdQ7, html code.shiki .svdQ7{--shiki-default:#D73A49;--shiki-github-dark:#F97583}html pre.shiki code .ssxIu, html code.shiki .ssxIu{--shiki-default:#24292E;--shiki-github-dark:#E1E4E8}html pre.shiki code .sIsaT, html code.shiki .sIsaT{--shiki-default:#6F42C1;--shiki-github-dark:#B392F0}html pre.shiki code .sJ6F3, html code.shiki .sJ6F3{--shiki-default:#032F62;--shiki-github-dark:#9ECBFF}html pre.shiki code .sdCPZ, html code.shiki .sdCPZ{--shiki-default:#6A737D;--shiki-github-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html.github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html pre.shiki code .snvgF, html code.shiki .snvgF{--shiki-default:#005CC5;--shiki-github-dark:#79B8FF}",{"title":95,"searchDepth":140,"depth":140,"links":1191},[1192,1193,1194,1196,1197,1198,1199,1201,1202,1203,1205,1207,1208,1210,1212],{"id":25,"depth":140,"text":26},{"id":59,"depth":140,"text":60},{"id":178,"depth":140,"text":1195},"The Copy Trait",{"id":288,"depth":140,"text":289},{"id":415,"depth":140,"text":416},{"id":476,"depth":140,"text":477},{"id":566,"depth":140,"text":1200},"Drop and Copy are Mutually Exclusive",{"id":590,"depth":140,"text":591},{"id":712,"depth":140,"text":713},{"id":778,"depth":140,"text":1204},"drop Order in Structs",{"id":888,"depth":140,"text":1206},"ManuallyDrop and MaybeUninit",{"id":908,"depth":140,"text":909},{"id":935,"depth":140,"text":1209},"Common Error: cannot move out of ...",{"id":1031,"depth":140,"text":1211},"mem::take and mem::replace",{"id":1148,"depth":140,"text":1149},"Ownership is the defining feature of Rust. Every other memory-safety guarantee flows from these rules.","md",{},"\u002Frust\u002F07-ownership",{"title":5,"description":1213},"rust\u002F07-ownership","ynT5fXIsaF86y-RgYNEb0ier6hxSHngrpx4_aSgIxBI",1785944093210]