百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rust-smallvec

> 编程语言
开源

对 Rust 的"小向量"优化: 在堆栈上存储最多少量的项

1.7K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

对 Rust 的"小向量"优化: 在堆栈上存储最多少量的项

rust-smallvec

[!WARNING] smallvec v2 is on pre-release

this means that there might be unexpected changes between versions. see the changelog for detailed breakdowns

changes include, but are not limited to:

  • breaking API changes
  • deprecation of items
  • adding, removing or modifying features

beware that this is a pre-release and we can't ensure that there are no vulnerabilities or corner cases. if this feels like a substantial risk to you, please downgrade to the latest v1 version

we are looking for people to test this v2 version, so feel free to play around with smallvec and use it for your purposes if this warning is not a concern, and please file an issue on the repo if you find some unexpected behavior or have a request for a feature

Release notes

Small vectors in various sizes. These store a certain number of elements inline, and fall back to the heap for larger allocations. This can be a useful optimization for improving cache locality and reducing allocator traffic for workloads that fit within the inline buffer.

Example

use smallvec::SmallVec;

// This SmallVec can hold up to 4 items on the stack:
let mut v: SmallVec<i32, 4> = SmallVec::from([1, 2, 3, 4]);

// It will automatically move its contents to the heap if
// contains more than four items:
v.push(5);

// SmallVec points to a slice, so you can use normal slice
// indexing and other methods to access its contents:
v[0] = v[1] + v[2];
v.sort();

Feature List

By default, SmallVec does not make use of any feature. SmallVec without any features enabled does not make use of the standard library.

  • arbitrary: implements Arbitrary for any SmallVec storing elements that implement Arbitrary
  • borsh: implements BorshSerialize, BorshDeserialize and BorshSchema
  • bytes: implements BufMut for SmallVec
  • defmt: implements defmt::Format for SmallVec
  • encase: implements encasing as a runtime-sized array
  • internals: exports through the public API TaggedLen and RawSmallVec
  • malloc_size_of: implements MallocSizeOf and MallocShallowSizeOf
  • may_dangle (nightly): enables the eyepatch optimization for dropping
  • rayon: implements parallel iteration
  • serde: implements serde's serialization and deserialization
  • specialization (nightly): enables specialization, improving performance on some cases
  • std: implements the std::io::Write type for SmallVec<u8, N>

The rayon feature implicitly requires std.

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言