(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[84016],{15525:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/en/build/smart-contracts/book/move-2.0",function(){return t(94839)}])},94839:function(e,n,t){"use strict";t.r(n),t.d(n,{useTOC:function(){return a}});var s=t(31549),i=t(82910),r=t(1117),o=t(46977);function a(e){return[]}n.default=(0,i.c)(function(e){let n={a:"a",code:"code",em:"em",h1:"h1",li:"li",p:"p",strong:"strong",ul:"ul",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{children:"Move 2.0 Language Release"}),"\n",(0,s.jsxs)(n.p,{children:["The Move 2.0 language release adds a number of new features to Move. The documentation of those features is integrated into the book, and marked in text with “",(0,s.jsx)(n.em,{children:"Since language version 2.0"}),"”. This section gives an overview of the new features and links to the documentation:"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Enum Types"})," add the option to define different variants of data layout in one storable type. They are documented in the ",(0,s.jsx)(n.a,{href:"enums",children:"Enum Type section"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Receiver Style Functions"})," add the ability to call functions in the familiar notation ",(0,s.jsx)(n.code,{children:"value.func(arg)"}),". They are documented in ",(0,s.jsx)(n.a,{href:"functions#dot-receiver-function-call-style",children:"this section"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Index Notation"})," allows to access ",(0,s.jsx)(n.a,{href:"vector#index-notation-for-vectors",children:"elements of vectors"})," and of ",(0,s.jsx)(n.a,{href:"global-storage-operators#index-notation-for-storage-operators",children:"resource storage"})," with notations like ",(0,s.jsx)(n.code,{children:"&mut vector[index]"}),", or ",(0,s.jsx)(n.code,{children:"&mut Resource[addr]"}),", respectively."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Positional Structs"})," allow to define wrapper types such as ",(0,s.jsx)(n.code,{children:"struct Wrapped(u64)"}),". Positional structs are described ",(0,s.jsx)(n.a,{href:"structs-and-resources#positional-structs",children:"here"}),". Enum variants are also allowed to be positional."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Dot-dot pattern wildcards"})," enable statements like ",(0,s.jsx)(n.code,{children:"let Struct{x, ..} = value"})," to match selective parts of data. They are described ",(0,s.jsx)(n.a,{href:"structs-and-resources#partial-patterns",children:"here"}),". Those patterns are also allowed for enum variants."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Package visibility"})," allows to declare a function to be visible anywhere inside, but not outside a package. Friend functions continue to be supported, although package visibility is in many cases more suitable. As a more concise notation, package and friend functions can be simply declared as ",(0,s.jsx)(n.code,{children:"package fun"})," or ",(0,s.jsx)(n.code,{children:"friend fun"}),", respectively, instead of the longer ",(0,s.jsx)(n.code,{children:"public(package) fun"})," and ",(0,s.jsx)(n.code,{children:"public(friend) fun"}),". This feature is documented ",(0,s.jsx)(n.a,{href:"functions#package-visibility",children:"here"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Assert abort code optional"})," The ",(0,s.jsx)(n.code,{children:"assert!"})," macro can now be used with just one argument, omitting the abort code, in which case a default code will be chosen. See also ",(0,s.jsx)(n.a,{href:"abort-and-assert#assert",children:"here"}),"."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"New Cast Syntax"})," Until now, casts had to always be in parentheses, requiring code like ",(0,s.jsx)(n.code,{children:"function((x as u256))"}),". This requirement is now dropped and casts can be top-level expressions without parenthesis, as in ",(0,s.jsx)(n.code,{children:"function(x as u256)"}),". One still needs to write ",(0,s.jsx)(n.code,{children:"(x as u64) + (y as u64)"})," in expressions. This similarly applies to the new enum variant test, ",(0,s.jsx)(n.code,{children:"data is VersionedData::V1"}),"."]}),"\n"]}),"\n"]})]})},"/en/build/smart-contracts/book/move-2.0",{filePath:"pages/en/build/smart-contracts/book/move-2.0.mdx",timestamp:1728425436e3,pageMap:r.v,frontMatter:{},title:"Move 2.0 Language Release"},"undefined"==typeof RemoteContent?a:RemoteContent.useTOC)},82910:function(e,n,t){"use strict";t.d(n,{c:function(){return c}});var s=t(31549),i=t(74271),r=t(14553),o=t(55754),a=t(46977);function c(e,n,t,s){let r=globalThis[i.ud];return r.route=n,r.pageMap=t.pageMap,r.context[n]={Content:e,pageOpts:t,useTOC:s},l}function l({__nextra_pageMap:e=[],__nextra_dynamic_opts:n,...t}){let a=globalThis[i.ud],{Layout:c,themeConfig:l}=a,{route:u,locale:h}=(0,r.t)(),f=a.context[u];if(!f)throw Error(`No content found for the "${u}" route. Please report it as a bug.`);let{pageOpts:p,useTOC:x,Content:j}=f;if(u.startsWith("/["))p.pageMap=e;else for(let{route:n,children:t}of e){let e=n.split("/").slice(h?2:1);(function e(n,[t,...s]){for(let i of n)if("children"in i&&t===i.name)return s.length?e(i.children,s):i})(p.pageMap,e).children=t}if(n){let{title:e,frontMatter:t}=n;p={...p,title:e,frontMatter:t}}return(0,s.jsx)(c,{themeConfig:l,pageOpts:p,pageProps:t,children:(0,s.jsx)(o.F,{value:t,children:(0,s.jsx)(d,{useTOC:x,children:(0,s.jsx)(j,{...t})})})})}function d({children:e,useTOC:n}){let{wrapper:t}=(0,a.a)();return(0,s.jsx)(u,{useTOC:n,wrapper:t,children:e})}function u({children:e,useTOC:n,wrapper:t,...i}){let r=n(i);return t?(0,s.jsx)(t,{toc:r,children:e}):e}}},function(e){e.O(0,[68889,1117,92888,49774,40179],function(){return e(e.s=15525)}),_N_E=e.O()}]);