mirror of
https://github.com/bspeice/speice.io
synced 2024-11-14 22:18:10 -05:00
1 line
3.2 KiB
JavaScript
1 line
3.2 KiB
JavaScript
"use strict";(self.webpackChunkspeice_io=self.webpackChunkspeice_io||[]).push([["8998"],{7508:function(e,t,n){n.r(t),n.d(t,{assets:function(){return l},contentTitle:function(){return s},default:function(){return d},frontMatter:function(){return r},metadata:function(){return o},toc:function(){return c}});var o=n(1495),i=n(5893),a=n(65);let r={slug:"2019/02/the-whole-world",title:"Allocations in Rust: Global memory",date:new Date("2019-02-05T12:00:00.000Z"),authors:["bspeice"],tags:[]},s=void 0,l={authorsImageUrls:[void 0]},c=[];function u(e){let t={a:"a",code:"code",em:"em",p:"p",...(0,a.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(t.p,{children:["The first memory type we'll look at is pretty special: when Rust can prove that a ",(0,i.jsx)(t.em,{children:"value"})," is fixed\nfor the life of a program (",(0,i.jsx)(t.code,{children:"const"}),"), and when a ",(0,i.jsx)(t.em,{children:"reference"})," is unique for the life of a program\n(",(0,i.jsx)(t.code,{children:"static"})," as a declaration, not\n",(0,i.jsx)(t.a,{href:"https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#the-static-lifetime",children:(0,i.jsx)(t.code,{children:"'static"})})," as a\nlifetime), we can make use of global memory. This special section of data is embedded directly in\nthe program binary so that variables are ready to go once the program loads; no additional\ncomputation is necessary."]}),"\n",(0,i.jsxs)(t.p,{children:["Understanding the value/reference distinction is important for reasons we'll go into below, and\nwhile the\n",(0,i.jsx)(t.a,{href:"https://github.com/rust-lang/rfcs/blob/master/text/0246-const-vs-static.md",children:"full specification"})," for\nthese two keywords is available, we'll take a hands-on approach to the topic."]})]})}function d(e={}){let{wrapper:t}={...(0,a.a)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},65:function(e,t,n){n.d(t,{Z:function(){return s},a:function(){return r}});var o=n(7294);let i={},a=o.createContext(i);function r(e){let t=o.useContext(a);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function s(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),o.createElement(a.Provider,{value:t},e.children)}},1495:function(e){e.exports=JSON.parse('{"permalink":"/2019/02/the-whole-world","source":"@site/blog/2019-02-05-the-whole-world/index.mdx","title":"Allocations in Rust: Global memory","description":"The first memory type we\'ll look at is pretty special: when Rust can prove that a value is fixed","date":"2019-02-05T12:00:00.000Z","tags":[],"readingTime":7.485,"hasTruncateMarker":true,"authors":[{"name":"Bradlee Speice","socials":{"github":"https://github.com/bspeice"},"key":"bspeice","page":null}],"frontMatter":{"slug":"2019/02/the-whole-world","title":"Allocations in Rust: Global memory","date":"2019-02-05T12:00:00.000Z","authors":["bspeice"],"tags":[]},"unlisted":false,"lastUpdatedAt":1731204300000,"prevItem":{"title":"Allocations in Rust: Fixed memory","permalink":"/2019/02/stacking-up"},"nextItem":{"title":"Allocations in Rust: Foreword","permalink":"/2019/02/understanding-allocations-in-rust"}}')}}]); |