We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
max_len
1 parent e247502 commit 1a2b6bdCopy full SHA for 1a2b6bd
docs/content/docs/references/space.mdx
@@ -101,5 +101,9 @@ pub struct Initialize<'info> {
101
A few important things to know:
102
103
- Don't forget the discriminator when defining `space`
104
-- The `max_len` length represents the length of the structure, not the total
105
- length. (ie: the `max_len` of a Vec\<u32\> will be `max_len` \* 4)
+- The `max_len` attribute specifies the maximum number of elements in a Vec, not the total size in bytes.
+ For example, if you specify `#[max_len(10)]` for a `Vec<u32>`, it means:
106
+ - Maximum 10 elements
107
+ - Each element (u32) takes 4 bytes
108
+ - The Vec itself has a 4-byte length prefix
109
+ - Total space = 4 + (10 * 4) = 44 bytes
0 commit comments