Skip to content

Commit 12acda2

Browse files
committed
deploy: afbe069
1 parent d21a539 commit 12acda2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

ch04-03-slices.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ <h2 id="切片型別"><a class="header" href="#切片型別">切片型別</a></h
192192
</span><span class="boring">
193193
</span><span class="boring">fn main() {}
194194
</span></code></pre>
195-
<p>我們會在<a href="ch13-02-iterators.html">第十三章</a><!-- ignore -->討論疊代器的細節。現在我們只需要知道 <code>iter</code> 是個能夠回傳集合中每個元素的方法,然後 <code>enumerate</code> 會將 <code>iter</code> 的結果包裝起來回傳成元組。<code>enumerate</code> 回傳的元組中的第一個元素是索引,第二個才是元素的參考。這樣比我們自己計算索引還來的方便。</p>
195+
<p>我們會在<a href="ch13-02-iterators.html">第十三章</a><!-- ignore -->討論疊代器的細節。現在我們只需要知道 <code>iter</code> 是個能夠回傳集合中每個元素的方法,然後 <code>enumerate</code> 會將 <code>iter</code> 的結果包裝起來回傳成元組(tuple)<code>enumerate</code> 回傳的元組中的第一個元素是索引,第二個才是元素的參考。這樣比我們自己計算索引還來的方便。</p>
196196
<p>既然 <code>enumerate</code> 回傳的是元組,我們可以用模式配對來解構元組。我們會在<a href="ch06-02-match.html#patterns-that-bind-to-values">第六章</a><!-- ignore -->進一步解釋模式配對。所以在 <code>for</code> 迴圈中,我們指定了一個模式讓 <code>i</code> 取得索引然後 <code>&amp;item</code> 取得元組中的位元組。因為我們從用 <code>.iter().enumerate()</code> 取得參考的,所以在模式中我們用的是 <code>&amp;</code> 來獲取。</p>
197197
<p><code>for</code> 迴圈裡面我們使用字串字面值的語法搜尋位元組是不是空格。如果我們找到空格的話,我們就回傳該位置。不然我們就用 <code>s.len()</code> 回傳整個字串的長度。</p>
198198
<pre><code class="language-rust ignore"><span class="boring">fn first_word(s: &amp;String) -&gt; usize {

print.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,7 @@ <h3 id="參考規則"><a class="header" href="#參考規則">參考規則</a></h
27192719
</span><span class="boring">
27202720
</span><span class="boring">fn main() {}
27212721
</span></code></pre>
2722-
<p>我們會在<a href="ch13-02-iterators.html">第十三章</a><!-- ignore -->討論疊代器的細節。現在我們只需要知道 <code>iter</code> 是個能夠回傳集合中每個元素的方法,然後 <code>enumerate</code> 會將 <code>iter</code> 的結果包裝起來回傳成元組。<code>enumerate</code> 回傳的元組中的第一個元素是索引,第二個才是元素的參考。這樣比我們自己計算索引還來的方便。</p>
2722+
<p>我們會在<a href="ch13-02-iterators.html">第十三章</a><!-- ignore -->討論疊代器的細節。現在我們只需要知道 <code>iter</code> 是個能夠回傳集合中每個元素的方法,然後 <code>enumerate</code> 會將 <code>iter</code> 的結果包裝起來回傳成元組(tuple)。<code>enumerate</code> 回傳的元組中的第一個元素是索引,第二個才是元素的參考。這樣比我們自己計算索引還來的方便。</p>
27232723
<p>既然 <code>enumerate</code> 回傳的是元組,我們可以用模式配對來解構元組。我們會在<a href="ch06-02-match.html#patterns-that-bind-to-values">第六章</a><!-- ignore -->進一步解釋模式配對。所以在 <code>for</code> 迴圈中,我們指定了一個模式讓 <code>i</code> 取得索引然後 <code>&amp;item</code> 取得元組中的位元組。因為我們從用 <code>.iter().enumerate()</code> 取得參考的,所以在模式中我們用的是 <code>&amp;</code> 來獲取。</p>
27242724
<p>在 <code>for</code> 迴圈裡面我們使用字串字面值的語法搜尋位元組是不是空格。如果我們找到空格的話,我們就回傳該位置。不然我們就用 <code>s.len()</code> 回傳整個字串的長度。</p>
27252725
<pre><code class="language-rust ignore"><span class="boring">fn first_word(s: &amp;String) -&gt; usize {

searchindex.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

searchindex.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)