|
| 1 | +<!-- |
1 | 2 | # Example: Implementing Vec
|
| 3 | +--> |
2 | 4 |
|
| 5 | +# 例: Vec の実装 |
| 6 | + |
| 7 | +<!-- |
3 | 8 | To bring everything together, we're going to write `std::Vec` from scratch.
|
4 | 9 | Because all the best tools for writing unsafe code are unstable, this
|
5 | 10 | project will only work on nightly (as of Rust 1.9.0). With the exception of the
|
6 | 11 | allocator API, much of the unstable code we'll use is expected to be stabilized
|
7 | 12 | in a similar form as it is today.
|
| 13 | +--> |
| 14 | + |
| 15 | +全てをまとめるために、最初から `std::Vec` を書くことにします。 |
| 16 | +アンセーフなコードを書くための最良のツールは全部アンステーブルなため、 |
| 17 | +このプロジェクトは nightly でしか動作しません (Rust 1.9.0 現在) 。 |
| 18 | +アロケータの API を除いて、使用するアンステーブルなもののほとんどは、 |
| 19 | +今日の形態に似た状態で、安定版となると予測しています。 |
8 | 20 |
|
| 21 | +<!-- |
9 | 22 | However we will generally try to avoid unstable code where possible. In
|
10 | 23 | particular we won't use any intrinsics that could make a code a little
|
11 | 24 | bit nicer or efficient because intrinsics are permanently unstable. Although
|
12 |
| -many intrinsics *do* become stabilized elsewhere (`std::ptr` and `str::mem` |
| 25 | +many intrinsics *do* become stabilized elsewhere (`std::ptr` and `std::mem` |
13 | 26 | consist of many intrinsics).
|
| 27 | +--> |
| 28 | + |
| 29 | +しかし、なるべくアンステーブルなコードを書くことを避けようと思います。 |
| 30 | +特に、いかなる intrinsic も使わないことにします。これらはコードを |
| 31 | +ちょっと改善したり、効率を良くします。これらを使わない理由は、 |
| 32 | +intrinsic が永遠にアンステーブルだからです。もっとも、多くの intrinsic は*実際に* |
| 33 | +別の場において安定版になっていますが (`std::ptr` や `std::mem` は、 |
| 34 | +多くの intrinsic を含んでいます) 。 |
14 | 35 |
|
| 36 | +<!-- |
15 | 37 | Ultimately this means our implementation may not take advantage of all
|
16 | 38 | possible optimizations, though it will be by no means *naive*. We will
|
17 | 39 | definitely get into the weeds over nitty-gritty details, even
|
18 | 40 | when the problem doesn't *really* merit it.
|
| 41 | +--> |
19 | 42 |
|
| 43 | +究極には、これは、ここで実装する Vec では可能な最適化を全部は |
| 44 | +利用しないということを意味します。だからといって、全く*単純*という訳ではありません。 |
| 45 | +その問題によって何か*本当に*利益を得ることがないとしても、基本的で |
| 46 | +細かいところに突っ込んでいきます。 |
| 47 | + |
| 48 | +<!-- |
20 | 49 | You wanted advanced. We're gonna go advanced.
|
| 50 | +--> |
| 51 | + |
| 52 | +先に進みたいですよね? それでは行きましょう。 |
0 commit comments