Skip to content

Added TinyVec::with_initial_len() function and associated tests. - #224

Merged
Lokathor merged 1 commit into
Lokathor:mainfrom
lordmulder:main
Aug 20, 2026
Merged

Added TinyVec::with_initial_len() function and associated tests.#224
Lokathor merged 1 commit into
Lokathor:mainfrom
lordmulder:main

Conversation

@lordmulder

Copy link
Copy Markdown
Contributor

Makes a default-initialized TinyVec with the given initial length.

If the requested length is less than or equal to the array capacity you
get an inline vec. If it's greater than you get a heap vec.

let t = TinyVec::<[u8; 10]>::with_initial_len(5);
assert!(t.is_inline());
assert_eq!(t.len(), 5);

let t = TinyVec::<[u8; 10]>::with_initial_len(20);
assert!(t.is_heap());
assert_eq!(t.len(), 20);

This fixes #210.

@Lokathor
Lokathor merged commit 62ea3a6 into Lokathor:main Aug 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to create a TinyVec of a specific size (not capacity!), initialized to zero (or user-defined value)

2 participants