标准库
Rust comes with a standard library which helps establish a set of common types used by Rust libraries and programs. This way, two libraries can work together smoothly because they both use the same String
type.
In fact, Rust contains several layers of the Standard Library: core
, alloc
and std
.
core
includes the most basic types and functions that don’t depend onlibc
, allocator or even the presence of an operating system.alloc
包括需要全局堆分配器的类型,例如Vec
、Box
和Arc
。- 嵌入式 Rust 应用通常只使用
core
,偶尔会使用alloc
。