Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 795624b

Browse files
committedFeb 5, 2016
generate
1 parent dcda24d commit 795624b

File tree

3 files changed

+80
-32
lines changed

3 files changed

+80
-32
lines changed
 

‎public/1.6/book/ownership.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ <h1 class="title">所有権</h1>
198198

199199
<!-- chapter: -->
200200

201-
<p>このガイドはRustの所有権システムの3つの解説の1つです
201+
<p>このガイドはRustの所有権システムの3つの解説の1つ目です
202202
これはRustの最も独特で注目されている機能です。そして、Rust開発者はそれについて高度に精通しておくべきです。
203203
所有権こそはRustがその最大の目標、メモリ安全性を得るための方法です。
204204
そこにはいくつかの別個の概念があり、各概念が独自の章を持ちます。</p>

‎public/1.6/book/references-and-borrowing.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ <h1 class="title">参照と借用</h1>
198198

199199
<!-- chapter: -->
200200

201-
<p>このガイドはRustの所有権システムの3つの解説の1つです
201+
<p>このガイドはRustの所有権システムの3つの解説の2つ目です
202202
これはRustの最も独特で注目されている機能です。そして、Rust開発者はそれについて高度に精通しておくべきです。
203203
所有権こそはRustがその最大の目標、メモリ安全性を得るための方法です。
204204
そこにはいくつかの別個の概念があり、各概念が独自の章を持ちます。</p>

‎public/1.6/book/unsized-types.html

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta name="generator" content="rustdoc">
7-
<title>Unsized Types</title>
7+
<title>サイズ不定型</title>
88

99
<link rel="stylesheet" type="text/css" href="rustbook.css">
1010

@@ -185,54 +185,97 @@
185185
<div id='page'>
186186

187187

188-
<h1 class="title">Unsized Types</h1>
189-
<p>Most types have a particular size, in bytes, that is knowable at compile time.
190-
For example, an <code>i32</code> is thirty-two bits big, or four bytes. However, there are
191-
some types which are useful to express, but do not have a defined size. These are
192-
called ‘unsized’ or ‘dynamically sized’ types. One example is <code>[T]</code>. This type
193-
represents a certain number of <code>T</code> in sequence. But we don’t know how many
194-
there are, so the size is not known.</p>
188+
<h1 class="title">サイズ不定型</h1>
189+
<!-- % Unsized Types -->
195190

196-
<p>Rust understands a few of these types, but they have some restrictions. There
197-
are three:</p>
191+
<!-- Most types have a particular size, in bytes, that is knowable at compile time. -->
192+
193+
<!-- For example, an `i32` is thirty-two bits big, or four bytes. However, there are -->
194+
195+
<!-- some types which are useful to express, but do not have a defined size. These are -->
196+
197+
<!-- called ‘unsized’ or ‘dynamically sized’ types. One example is `[T]`. This type -->
198+
199+
<!-- represents a certain number of `T` in sequence. But we don’t know how many -->
200+
201+
<!-- there are, so the size is not known. -->
202+
203+
<p>ほとんどの型はコンパイル時に知れる、バイト数で測った、サイズがあります。
204+
例えば、 <code>i32</code> 型は、32ビット(4バイト)というサイズです。
205+
しかしながら、表現のためには便利であってもサイズが定まっていない型が存在します。
206+
そのような方を 「サイズ不定」又は「動的サイズ」型と呼びます。
207+
一例を上げると <code>[T]</code> 型は 一定のサイズの<code>T</code> のシーケンスを意味していますが、その要素数については規定されていないため、サイズは不定となります。</p>
208+
209+
<!-- Rust understands a few of these types, but they have some restrictions. There -->
210+
211+
<!-- are three: -->
212+
213+
<p>Rustはいくつかのそのような型を扱うことができますが、それらには以下の様な3つの制約が存在します:</p>
214+
215+
<!-- 1. We can only manipulate an instance of an unsized type via a pointer. An ->
216+
<!-- `&[T]` works just fine, but a `[T]` does not. -->
217+
218+
<!-- 2. Variables and arguments cannot have dynamically sized types. -->
219+
220+
<!-- 3. Only the last field in a `struct` may have a dynamically sized type; the -->
221+
222+
<!-- other fields must not. Enum variants must not have dynamically sized types as -->
223+
224+
<!-- data. -->
198225

199226
<ol>
200-
<li>We can only manipulate an instance of an unsized type via a pointer. An
201-
<code>&amp;[T]</code> works just fine, but a <code>[T]</code> does not.</li>
202-
<li>Variables and arguments cannot have dynamically sized types.</li>
203-
<li>Only the last field in a <code>struct</code> may have a dynamically sized type; the
204-
other fields must not. Enum variants must not have dynamically sized types as
205-
data.</li>
227+
<li>サイズ不定型はポインタを通してのみ操作することができます、たとえば、 <code>&amp;[T]</code> は大丈夫ですが、 <code>[T]</code> はそうではありません。</li>
228+
<li>変数や引数は動的なサイズを持つことはできません。</li>
229+
<li><code>struct</code> の最後のフィールドのみ、動的なサイズを持つことが許されます、その他のフィールドはサイズが不定であってはなりません。
230+
また、Enumのバリアントはデータとして動的なサイズの型を持つ事はできません。</li>
206231
</ol>
207232

208-
<p>So why bother? Well, because <code>[T]</code> can only be used behind a pointer, if we
209-
didn’t have language support for unsized types, it would be impossible to write
210-
this:</p>
233+
<!-- So why bother? Well, because `[T]` can only be used behind a pointer, if we -->
234+
235+
<!-- didn’t have language support for unsized types, it would be impossible to write -->
236+
237+
<!-- this: -->
238+
239+
<p>なぜこんなにややこしいのでしょうか? これは、<code>[T]</code> はポインタを通してのみ操作可能であるため、
240+
もし言語がサイズ不定型をサポートしていなかった場合、以下のようなコードを書くことは不可能となります:</p>
211241
<span class='rusttest'>fn main() {
212242
impl Foo for str {
213243
}</span><pre class='rust rust-example-rendered'>
214244
<span class='kw'>impl</span> <span class='ident'>Foo</span> <span class='kw'>for</span> <span class='ident'>str</span> {</pre>
215245

216-
<p>or</p>
246+
<!-- or -->
247+
248+
<p>また、以下の様なコードも:</p>
217249
<span class='rusttest'>fn main() {
218250
impl&lt;T&gt; Foo for [T] {
219251
}</span><pre class='rust rust-example-rendered'>
220252
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='ident'>T</span><span class='op'>&gt;</span> <span class='ident'>Foo</span> <span class='kw'>for</span> [<span class='ident'>T</span>] {</pre>
221253

222-
<p>Instead, you would have to write:</p>
254+
<!-- Instead, you would have to write: -->
255+
256+
<p>このように書く代わりに、以下のように書く必要があることになるでしょう:</p>
223257
<span class='rusttest'>fn main() {
224258
impl Foo for &amp;str {
225259
}</span><pre class='rust rust-example-rendered'>
226260
<span class='kw'>impl</span> <span class='ident'>Foo</span> <span class='kw'>for</span> <span class='kw-2'>&amp;</span><span class='ident'>str</span> {</pre>
227261

228-
<p>Meaning, this implementation would only work for <a href="references-and-borrowing.html">references</a>, and not
229-
other types of pointers. With the <code>impl for str</code>, all pointers, including (at
230-
some point, there are some bugs to fix first) user-defined custom smart
231-
pointers, can use this <code>impl</code>.</p>
262+
<!-- Meaning, this implementation would only work for [references][ref], and not -->
263+
264+
<!-- other types of pointers. With the `impl for str`, all pointers, including (at -->
265+
266+
<!-- some point, there are some bugs to fix first) user-defined custom smart -->
267+
268+
<!-- pointers, can use this `impl`. -->
269+
270+
<p>このように書いたとすると、このコードは <a href="references-and-borrowing.html">参照</a> に対してのみ動作する用になり、他のポインタ型に対しては動作しないことになります。
271+
<code>imp for str</code> のように書くことで、すべてのポインタ、ユーザーの定義した独自のスマートポインタ(いくつかの点についてバグがあるので、それを先ずは直さなくてはなりませんが)もこの <code>impl</code> を利用可能になります。</p>
232272

233273
<h1 id='sized' class='section-header'><a href='#sized'>?Sized</a></h1>
234-
<p>If you want to write a function that accepts a dynamically sized type, you
235-
can use the special bound, <code>?Sized</code>:</p>
274+
<!-- If you want to write a function that accepts a dynamically sized type, you -->
275+
276+
<!-- can use the special bound, `?Sized`: -->
277+
278+
<p>もし動的サイズ型を引数に取れるような関数を定義したい場合、特別な境界 <code>?Sized</code> を利用できます:</p>
236279
<span class='rusttest'>fn main() {
237280
struct Foo&lt;T: ?Sized&gt; {
238281
f: T,
@@ -242,9 +285,14 @@ <h1 id='sized' class='section-header'><a href='#sized'>?Sized</a></h1>
242285
<span class='ident'>f</span>: <span class='ident'>T</span>,
243286
}</pre>
244287

245-
<p>This <code>?</code>, read as “T may be <code>Sized</code>”, means that this bound is special: it
246-
lets us match more kinds, not less. It’s almost like every <code>T</code> implicitly has
247-
<code>T: Sized</code>, and the <code>?</code> undoes this default.</p>
288+
<!-- This `?`, read as “T may be `Sized`”, means that this bound is special: it -->
289+
290+
<!-- lets us match more kinds, not less. It’s almost like every `T` implicitly has -->
291+
292+
<!-- `T: Sized`, and the `?` undoes this default. -->
293+
294+
<p><code>?</code> は 「Tは <code>Sized</code> かもしれない」と読みます、これは <code>?</code> が特別な境界: より小さいカインドとマッチするのではなく、より大きいカインドとマッチする ということを意味しています。
295+
これは、すべての <code>T</code> は暗黙的に <code>T : Sized</code> という制限がかけられていて、 <code>?</code> はその制限を解除するというようなものです。</p>
248296

249297
<script type="text/javascript">
250298
window.playgroundUrl = "https://play.rust-lang.org";

0 commit comments

Comments
 (0)
Please sign in to comment.