Skip to content

Commit 189bea6

Browse files
committed
ci: generate pages at 97d6e0c [ci skip]
1 parent 97d6e0c commit 189bea6

File tree

24 files changed

+299
-181
lines changed

24 files changed

+299
-181
lines changed

docs/conversion/string.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ <h2 id="stringへの型変換"><a class="header" href="#stringへの型変換">S
181181
-->
182182
<h2 id="stringの解析"><a class="header" href="#stringの解析">Stringの解析</a></h2>
183183
<!--
184-
One of the more common types to convert a string into is a number. The idiomatic
184+
One of the more common types to convert a string into a number. The idiomatic
185185
approach to this is to use the [`parse`] function and either to arrange for
186186
type inference or to specify the type to parse using the 'turbofish' syntax.
187187
Both alternatives are shown in the following example.

docs/crates/lib.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ <h1 id="ライブラリ"><a class="header" href="#ライブラリ">ライブラ
153153
Let's create a library, and then see how to link it to another crate.
154154
-->
155155
<p>ではライブラリを作成し、それを別のクレートにリンクする方法を見ていきましょう。</p>
156+
<p>In <code>rary.rs</code>:</p>
156157
<pre><code class="language-rust ignore">pub fn public_function() {
157158
println!(&quot;called rary's `public_function()`&quot;);
158159
}

docs/error/multiple_error_types/reenter_question_mark.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ <h1 id="の他の活用法"><a class="header" href="#の他の活用法"><code>?
155155
error:
156156
-->
157157
<p>以前の例では<code>parse</code>の呼び出しに対するその場での対応として、エラーをライブラリのエラーからboxされたエラーへと<code>map</code>していました。</p>
158-
<pre><code class="language-rust ignore">.and_then(|s| s.parse::&lt;i32&gt;()
158+
<pre><code class="language-rust ignore">.and_then(|s| s.parse::&lt;i32&gt;())
159159
.map_err(|e| e.into())</code></pre>
160160
<!--
161161
Since this is a simple and common operation, it would be convenient if it

docs/error/option_unwrap/and_then.html

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ <h1 id="combinators-and_then"><a class="header" href="#combinators-and_then">Com
159159
-->
160160
<p><code>and_then()</code>は引数として与えられた関数にラップされた値を渡しますが、その値が<code>None</code>だった場合は<code>None</code>を返します。</p>
161161
<!--
162-
In the following example, `cookable_v2()` results in an `Option<Food>`.
162+
In the following example, `cookable_v3()` results in an `Option<Food>`.
163163
Using `map()` instead of `and_then()` would have given an
164164
`Option<Option<Food>>`, which is an invalid type for `eat()`.
165165
-->
166-
<p>以下の例では<code>cookable_v2()</code><code>Option&lt;Food&gt;</code>を返すため、<code>and_then()</code>ではなく<code>map()</code>を使用すると最終的に<code>Option&lt;Option&lt;Food&gt;&gt;</code>になります。これは<code>eat()</code>には不適切な型です。</p>
166+
<p>以下の例では<code>cookable_v3()</code><code>Option&lt;Food&gt;</code>を返すため、<code>and_then()</code>ではなく<code>map()</code>を使用すると最終的に<code>Option&lt;Option&lt;Food&gt;&gt;</code>になります。これは<code>eat()</code>には不適切な型です。</p>
167167
<pre><pre class="playground"><code class="language-rust editable edition2021">#![allow(dead_code)]
168168

169169
#[derive(Debug)] enum Food { CordonBleu, Steak, Sushi }
@@ -194,21 +194,24 @@ <h1 id="combinators-and_then"><a class="header" href="#combinators-and_then">Com
194194
fn cookable_v1(food: Food) -&gt; Option&lt;Food&gt; {
195195
match have_recipe(food) {
196196
None =&gt; None,
197-
Some(food) =&gt; match have_ingredients(food) {
198-
None =&gt; None,
199-
Some(food) =&gt; Some(food),
200-
},
197+
Some(food) =&gt; have_ingredients(food),
201198
}
202199
}
203200

204201
// This can conveniently be rewritten more compactly with `and_then()`:
205202
// `and_then()`を用いることで、同じことをよりコンパクトに表現できる。
206-
fn cookable_v2(food: Food) -&gt; Option&lt;Food&gt; {
203+
fn cookable_v3(food: Food) -&gt; Option&lt;Food&gt; {
207204
have_recipe(food).and_then(have_ingredients)
208205
}
209206

207+
// Otherwise we'd need to `flatten()` an `Option&lt;Option&lt;Food&gt;&gt;`
208+
// to get an `Option&lt;Food&gt;`:
209+
fn cookable_v2(food: Food) -&gt; Option&lt;Food&gt; {
210+
have_recipe(food).map(have_ingredients).flatten()
211+
}
212+
210213
fn eat(food: Food, day: Day) {
211-
match cookable_v2(food) {
214+
match cookable_v3(food) {
212215
Some(food) =&gt; println!(&quot;Yay! On {:?} we get to eat {:?}.&quot;, day, food),
213216
None =&gt; println!(&quot;Oh no. We don't get to eat on {:?}?&quot;, day),
214217
}
@@ -226,9 +229,8 @@ <h1 id="combinators-and_then"><a class="header" href="#combinators-and_then">Com
226229
-->
227230
<h3 id="参照"><a class="header" href="#参照">参照</a></h3>
228231
<!--
229-
[closures][closures], [`Option`][option], and [`Option::and_then()`][and_then]
230232
-->
231-
<p><a href="../../fn/closures.html">closures</a>, <a href="https://doc.rust-lang.org/std/option/enum.Option.html"><code>Option</code></a>, <a href="https://doc.rust-lang.org/std/option/enum.Option.html#method.and_then"><code>Option::and_then()</code></a></p>
233+
<p><a href="../../fn/closures.html">closures</a>, <a href="https://doc.rust-lang.org/std/option/enum.Option.html"><code>Option</code></a>, <a href="https://doc.rust-lang.org/std/option/enum.Option.html#method.and_then"><code>Option::and_then()</code></a>, and <a href="https://doc.rust-lang.org/std/option/enum.Option.html#method.flatten"><code>Option::flatten()</code></a></p>
232234

233235
</main>
234236

docs/error/result/result_map.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ <h1 id="resultのmap"><a class="header" href="#resultのmap"><code>Result</code>
212212

213213
// As with `Option`, we can use combinators such as `map()`.
214214
// This function is otherwise identical to the one above and reads:
215-
// Modify n if the value is valid, otherwise pass on the error.
215+
// Multiply if both values can be parsed from str, otherwise pass on the error.
216216
// `Option`と同様、`map()`などのコンビネータを使うことができます。
217217
// この関数は`map()`を使っている点以外は上記の関数と同じで、
218-
// 値が有効ならnを変更し、無効であればエラーをそのまま見送ります。
218+
// 両方の値がstrからパース可能であればそれらを乗算し、無効であればエラーをそのまま見送ります。
219219
fn multiply(first_number_str: &amp;str, second_number_str: &amp;str) -&gt; Result&lt;i32, ParseIntError&gt; {
220220
first_number_str.parse::&lt;i32&gt;().and_then(|first_number| {
221221
second_number_str.parse::&lt;i32&gt;().map(|second_number| first_number * second_number)

docs/flow_control/let_else.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ <h1 class="menu-title">Rust By Example 日本語版</h1>
148148
<h1 id="let-else"><a class="header" href="#let-else">let-else</a></h1>
149149
<blockquote>
150150
<p>🛈 stable since: rust 1.65</p>
151+
<p>🛈 you can target specific edition by compiling like this
152+
<code>rustc --edition=2021 main.rs</code></p>
151153
</blockquote>
152154
<p>With <code>let</code>-<code>else</code>, a refutable pattern can match and bind variables
153155
in the surrounding scope like a normal <code>let</code>, or else diverge (e.g. <code>break</code>,
154156
<code>return</code>, <code>panic!</code>) when the pattern doesn't match.</p>
155-
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
156-
</span><span class="boring">fn main() {
157-
</span>use std::str::FromStr;
157+
<pre><pre class="playground"><code class="language-rust edition2021">use std::str::FromStr;
158158

159159
fn get_count_item(s: &amp;str) -&gt; (u64, &amp;str) {
160160
let mut it = s.split(' ');
@@ -167,8 +167,9 @@ <h1 id="let-else"><a class="header" href="#let-else">let-else</a></h1>
167167
(count, item)
168168
}
169169

170-
assert_eq!(get_count_item(&quot;3 chairs&quot;), (3, &quot;chairs&quot;));
171-
<span class="boring">}</span></code></pre></pre>
170+
fn main() {
171+
assert_eq!(get_count_item(&quot;3 chairs&quot;), (3, &quot;chairs&quot;));
172+
}</code></pre></pre>
172173
<p>The scope of name bindings is the main thing that makes this different from
173174
<code>match</code> or <code>if let</code>-<code>else</code> expressions. You could previously approximate these
174175
patterns with an unfortunate bit of repetition and an outer <code>let</code>:</p>

docs/flow_control/match/destructuring/destructure_structures.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ <h1 id="構造体"><a class="header" href="#構造体">構造体</a></h1>
179179
// `x`に言及していないため、以下はエラーになる。
180180
//Foo { y } =&gt; println!(&quot;y = {}&quot;, y),
181181
}
182+
183+
let faa = Foo { x: (1, 2), y: 3 };
184+
185+
// You do not need a match block to destructure structs:
186+
let Foo { x : x0, y: y0 } = faa;
187+
println!(&quot;Outside: x0 = {x0:?}, y0 = {y0}&quot;);
182188
}</code></pre></pre>
183189
<!--
184190
### See also:

docs/flow_control/match/guard.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ <h1 id="ガード"><a class="header" href="#ガード">ガード</a></h1>
153153
A `match` *guard* can be added to filter the arm.
154154
-->
155155
<p><code>match</code>内の条件文をフィルタリングするために、 <em>ガード(<code>guard</code>)</em> を使用することができます。</p>
156-
<pre><pre class="playground"><code class="language-rust editable edition2021">enum Temperature {
156+
<pre><pre class="playground"><code class="language-rust editable edition2021">#[allow(dead_code)]
157+
enum Temperature {
157158
Celsius(i32),
158159
Fahrenheit(i32),
159160
}

docs/generics/bounds.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ <h1 id="ジェネリック境界"><a class="header" href="#ジェネリック境
218218
let _triangle = Triangle { length: 3.0, height: 4.0 };
219219

220220
print_debug(&amp;rectangle);
221-
println!(&quot;Area: {}&quot;, rectangle.area());
221+
println!(&quot;Area: {}&quot;, area(&amp;rectangle));
222222

223223
//print_debug(&amp;_triangle);
224-
//println!(&quot;Area: {}&quot;, _triangle.area());
224+
//println!(&quot;Area: {}&quot;, area(&amp;_triangle));
225225
// ^ TODO: Try uncommenting these.
226226
// | Error: Does not implement either `Debug` or `HasArea`.
227227
// ^ TODO: これらの行をアンコメントしてみましょう。

docs/hello/comment.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ <h1 id="コメント"><a class="header" href="#コメント">コメント</a></h
179179
<pre><pre class="playground"><code class="language-rust editable edition2021">fn main() {
180180
// This is an example of a line comment.
181181
// There are two slashes at the beginning of the line.
182-
// And nothing written inside these will be read by the compiler.
182+
// And nothing written after these will be read by the compiler.
183183
// こちらはラインコメントです
184184
// 一番左にスラッシュが2つある行と、何も書かれていない行は
185185
// どちらもコンパイラによって無視されます。試しに実行してみてください

0 commit comments

Comments
 (0)