From 48f7819e74b497375f9e4de4518622c514b59f19 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Mon, 8 May 2023 19:18:37 +0200 Subject: [PATCH] fix wrong link --- src/routes/posts/rust-basics/+page.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/posts/rust-basics/+page.md b/src/routes/posts/rust-basics/+page.md index 6caf23e..1b21370 100644 --- a/src/routes/posts/rust-basics/+page.md +++ b/src/routes/posts/rust-basics/+page.md @@ -213,7 +213,7 @@ Stack: Primitives and basic [`struct{:rust}`](#declaring-structs)s are stored on the stack. To get values onto heap, you can use [`Box{:rust}`](#boxlttgt). [`Vec{:rust}`](#veclttgt) also puts it's values onto heap. -You may need to use heap if you're using a bit more RAM or if you need to use [`enum{:rust}`](#enums)s with values in structs (basically, if rust complains that a size is unknown at compile time, easiest option is to somehow put it onto heap). +You may need to use heap if you're using a bit more RAM or if you need to use [`enum{:rust}`](#declaring-enums)s with values in structs (basically, if rust complains that a size is unknown at compile time, easiest option is to somehow put it onto heap). If you see a stackoverflow, you're using too much stack memory. Try [`box{:rust}`](#boxlttgt)ing some bigger (and perhaps rarely used) values. Note that while heap is slower, it's still plenty fast (as for example almost all JS values are stored on heap, it will always be faster with rust). #### Common primitives @@ -281,7 +281,7 @@ Javascript arrays behave sort of like `Vec{:rust}` - they have a set limit, and ##### Box<T> -Stores `T` on heap. Useful for using [`enum`s](#enums) in structs, or to free up stack space. +Stores `T` on heap. Useful for using [`enum`s](#declaring-enums) in structs, or to free up stack space. See also [heap vs stack](#heap-vs-stack). @@ -311,7 +311,7 @@ struct Something { struct Something = u8; // a single value ``` -As stated earlier, `struct` **sizes are static**. This means you cannot use [`enum{:rust}`s](#enums) with self-referencing (recursive) values directly in `struct{:rust}`s. +As stated earlier, `struct` **sizes are static**. This means you cannot use [`enum{:rust}`s](#declaring-enums) with self-referencing (recursive) values directly in `struct{:rust}`s. One of possible ``workarounds'' is to use the [heap](#heap-vs-stack) for actually storing the values, for example by using [Box<T>](#boxlttgt). ```rust