mirror of https://github.com/rust-lang/nomicon
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
991 B
21 lines
991 B
8 years ago
|
# Example: Implementing Vec
|
||
10 years ago
|
|
||
|
To bring everything together, we're going to write `std::Vec` from scratch.
|
||
10 years ago
|
Because all the best tools for writing unsafe code are unstable, this
|
||
9 years ago
|
project will only work on nightly (as of Rust 1.9.0). With the exception of the
|
||
10 years ago
|
allocator API, much of the unstable code we'll use is expected to be stabilized
|
||
|
in a similar form as it is today.
|
||
10 years ago
|
|
||
10 years ago
|
However we will generally try to avoid unstable code where possible. In
|
||
|
particular we won't use any intrinsics that could make a code a little
|
||
|
bit nicer or efficient because intrinsics are permanently unstable. Although
|
||
|
many intrinsics *do* become stabilized elsewhere (`std::ptr` and `str::mem`
|
||
|
consist of many intrinsics).
|
||
|
|
||
9 years ago
|
Ultimately this means our implementation may not take advantage of all
|
||
10 years ago
|
possible optimizations, though it will be by no means *naive*. We will
|
||
|
definitely get into the weeds over nitty-gritty details, even
|
||
|
when the problem doesn't *really* merit it.
|
||
|
|
||
|
You wanted advanced. We're gonna go advanced.
|