auto merge of #11507 : omasanori/rust/reduce-po, r=alexcrichton

This work is done by execute these commands manually:

    $ po4a --copyright-holders="The Rust Project Developers" \
        --package-name="Rust" \
        --package-version="0.10-pre" \
        -M UTF-8 -L UTF-8 \
        doc/po4a.conf
    $ for f in doc/po/**/*.po; do
    >   msgattrib --untranslated $f -o $f.strip
    >   if [ -e $f.strip ]; then
    >       mv $f.strip $f
    >   else
    >       rm $f
    >   fi
    > done

It should be managed by the build system automatically to use in our
translation workflow, but I've not yet done that.

At least one mostly-translated (over 80% translation rate) document is needed to test the translation workflow, so I'll working on Japanese translation.
This commit is contained in:
bors 2014-01-14 09:56:39 -08:00
commit d150f6b442
23 changed files with 3918 additions and 13208 deletions

View File

@ -8,6 +8,12 @@ source code.
the Markdown docs (reference manual, tutorials, etc.) distributed with
this git repository.
[po4a](http://po4a.alioth.debian.org/) is required for generating translated
docs from the master (English) docs.
[GNU gettext](http://www.gnu.org/software/gettext/) is required for managing
the translation data.
# Building
To generate all the docs, just run `make docs` from the root of the repository.
@ -38,3 +44,43 @@ http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
A nice quick reference (for non-pandoc markdown) is at:
http://kramdown.rubyforge.org/quickref.html
# Notes for translators
Notice: The procedure described below is a work in progress. We are working on
translation system but the procedure contains some manual operations for now.
To start the translation for a new language, see po4a.conf at first.
To generate .pot and .po files, do something like:
~~~~
po4a --copyright-holder="The Rust Project Developers" \
--package-name="Rust" \
--package-version="0.10-pre" \
-M UTF-8 -L UTF-8 \
po4a.conf
~~~~
(the version number must be changed if it is not 0.10-pre now.)
Now you can translate documents with .po files, commonly used with gettext. If
you are not familiar with gettext-based translation, please read the online
manual linked from http://www.gnu.org/software/gettext/ . We use UTF-8 as the
file encoding of .po files.
When you want to make a commit, do the command below before staging your
change:
~~~~
for f in doc/po/**/*.po; do
msgattrib --translated $f -o $f.strip
if [ -e $f.strip ]; then
mv $f.strip $f
else
rm $f
fi
done
~~~~
This removes untranslated entries from .po files to save disk space.

View File

@ -0,0 +1,152 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/complement-cheatsheet.md:13
#, fuzzy
#| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "~~~ let x: int = 42; let y: ~str = x.to_str(); ~~~"
msgstr ""
"~~~~\n"
"let x: f64 = 4.0;\n"
"let y: uint = x as uint;\n"
"assert!(y == 4u);\n"
"~~~~"
#. type: Plain text
#: doc/complement-cheatsheet.md:17
#, fuzzy
#| msgid ""
#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
msgid ""
"Use [`FromStr`](http://static.rust-lang.org/doc/master/std/from_str/trait."
"FromStr.html), and its helper function, [`from_str`](http://static.rust-lang."
"org/doc/master/std/from_str/fn.from_str.html)."
msgstr ""
"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
#. type: Plain text
#: doc/complement-cheatsheet.md:22
#, fuzzy
#| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "~~~ let x: Option<int> = from_str(\"42\"); let y: int = x.unwrap(); ~~~"
msgstr ""
"~~~~\n"
"let x: f64 = 4.0;\n"
"let y: uint = x as uint;\n"
"assert!(y == 4u);\n"
"~~~~"
#. type: Plain text
#: doc/complement-cheatsheet.md:29
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ use std::num::ToStrRadix;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/complement-cheatsheet.md:33
#, fuzzy
#| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "let x: int = 42; let y: ~str = x.to_str_radix(16); ~~~"
msgstr ""
"~~~~\n"
"let x: f64 = 4.0;\n"
"let y: uint = x as uint;\n"
"assert!(y == 4u);\n"
"~~~~"
#. type: Plain text
#: doc/complement-cheatsheet.md:37
#, fuzzy
#| msgid ""
#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
msgid ""
"Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait."
"FromStrRadix.html), and its helper function, [`from_str_radix`](http://"
"static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html)."
msgstr ""
"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
#. type: Plain text
#: doc/complement-cheatsheet.md:40
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ use std::num::from_str_radix;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/complement-cheatsheet.md:46
#, fuzzy
#| msgid "## Operators"
msgid "# File operations"
msgstr "## 演算子"
#. type: Plain text
#: doc/complement-cheatsheet.md:54
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ {.xfail-test} use std::path::Path; use std::io::fs::File;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/complement-cheatsheet.md:63
#, fuzzy
#| msgid ""
#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
msgid ""
"Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer."
"html#method.lines) method on a [`BufferedReader`](http://static.rust-lang."
"org/doc/master/std/io/buffered/struct.BufferedReader.html)."
msgstr ""
"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
#. type: Plain text
#: doc/complement-cheatsheet.md:77
#, fuzzy
#| msgid "## Using other crates"
msgid "# String operations"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/complement-cheatsheet.md:88 doc/guide-container.md:4
#, fuzzy
msgid "# Containers"
msgstr "## 本書の表記について"
#. type: Plain text
#: doc/complement-cheatsheet.md:176
#, fuzzy
#| msgid "[The foreign function interface][ffi]"
msgid "# FFI (Foreign Function Interface)"
msgstr "[他言語間インターフェース (foreign function inferface)][ffi]"

View File

@ -0,0 +1,47 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/complement-lang-faq.md:83
#, fuzzy
#| msgid ""
#| "[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: "
#| "https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust"
msgid ""
"[rustc]: https://github.com/mozilla/rust/tree/master/src/librustc [resolve]: "
"https://github.com/mozilla/rust/blob/master/src/librustc/middle/resolve.rs "
"[borrowck]: https://github.com/mozilla/rust/blob/master/src/librustc/middle/"
"borrowck/"
msgstr ""
"[bug-3319]: https://github.com/mozilla/rust/issues/3319\n"
"[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-"
"developing-Rust"
#. type: Plain text
#: doc/complement-lang-faq.md:110
#, fuzzy
#| msgid ""
#| "[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: "
#| "https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust"
msgid ""
"[unwind]: https://github.com/mozilla/rust/issues/908 [libgcc]: https://"
"github.com/mozilla/rust/issues/1603"
msgstr ""
"[bug-3319]: https://github.com/mozilla/rust/issues/3319\n"
"[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-"
"developing-Rust"

View File

@ -0,0 +1,24 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Bullet: '* '
#: doc/complement-project-faq.md:36
#, fuzzy
#| msgid "## The standard library"
msgid "An evolving standard library."
msgstr "## 標準ライブラリ"

View File

@ -0,0 +1,73 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Condition and Error-handling Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Bullet: ' - '
#: doc/guide-conditions.md:14
#, fuzzy
#| msgid "# Functions"
msgid "Options"
msgstr "# 関数"
#. type: Bullet: ' - '
#: doc/guide-conditions.md:14
#, fuzzy
#| msgid "## Conditionals"
msgid "Conditions"
msgstr "## 条件式"
#. type: Plain text
#: doc/guide-conditions.md:19
#, fuzzy
#| msgid "## Tuples"
msgid "# Example program"
msgstr "## タプル"
#. type: Plain text
#: doc/guide-conditions.md:112
#, fuzzy
#| msgid "# Functions"
msgid "# Options"
msgstr "# 関数"
#. type: Plain text
#: doc/guide-conditions.md:318
#, fuzzy
#| msgid "## Conditionals"
msgid "# Conditions"
msgstr "## 条件式"
#. type: Plain text
#: doc/guide-conditions.md:415
#, fuzzy
#| msgid "## Traits"
msgid "# Trapping a condition"
msgstr "## トレイト"

View File

@ -0,0 +1,114 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/complement-cheatsheet.md:88 doc/guide-container.md:4
#, fuzzy
msgid "# Containers"
msgstr "## 本書の表記について"
#. type: Plain text
#: doc/guide-container.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Containers and Iterators Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-container.md:8
#, fuzzy
#| msgid "# Control structures"
msgid "## Unique vectors"
msgstr "# 制御構造"
#. type: Plain text
#: doc/guide-container.md:18
#, fuzzy
#| msgid "## Managed closures"
msgid "## Maps and sets"
msgstr "## マネージドクロージャ"
#. type: Plain text
#: doc/guide-container.md:24
#, fuzzy
#| msgid "## The standard library"
msgid "The standard library provides three owned map/set types:"
msgstr "## 標準ライブラリ"
#. type: Plain text
#: doc/guide-container.md:68
#, fuzzy
#| msgid "## Operators"
msgid "# Iterators"
msgstr "## 演算子"
#. type: Plain text
#: doc/guide-container.md:70
#, fuzzy
#| msgid "# Introduction"
msgid "## Iteration protocol"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-container.md:119
#, fuzzy
#| msgid "# Control structures"
msgid "## Container iterators"
msgstr "# 制御構造"
#. type: Plain text
#: doc/guide-container.md:131
#, fuzzy
#| msgid "## Freezing"
msgid "### Freezing"
msgstr "## 凍結"
#. type: Plain text
#: doc/guide-container.md:151
#, fuzzy
#| msgid "## Operators"
msgid "## Iterator adaptors"
msgstr "## 演算子"
#. type: Plain text
#: doc/guide-container.md:201
#, fuzzy
#| msgid "## Loops"
msgid "## For loops"
msgstr "## ループ"
#. type: Plain text
#: doc/guide-container.md:257
#, fuzzy
#| msgid "## Conventions"
msgid "## Conversion"
msgstr "## 本書の表記について"
#. type: Plain text
#: doc/guide-container.md:334
#, fuzzy
#| msgid "# Control structures"
msgid "## Double-ended iterators"
msgstr "# 制御構造"
#. type: Plain text
#: doc/guide-container.md:385
#, fuzzy
#| msgid "# Control structures"
msgid "## Random-access iterators"
msgstr "# 制御構造"

82
doc/po/ja/guide-ffi.md.po Normal file
View File

@ -0,0 +1,82 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-ffi.md:2
#, fuzzy
#| msgid "[The foreign function interface][ffi]"
msgid "% The Rust Foreign Function Interface Guide"
msgstr "[他言語間インターフェース (foreign function inferface)][ffi]"
#. type: Plain text
#: doc/guide-ffi.md:16
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~~ {.xfail-test} use std::libc::size_t;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-ffi.md:48
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~~ {.xfail-test} use std::libc::{c_int, size_t};"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-ffi.md:168 doc/tutorial.md:875
msgid "# Destructors"
msgstr "# デストラクタ"
#. type: Plain text
#: doc/guide-ffi.md:333
#, fuzzy
#| msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
msgid "~~~~ unsafe fn kaboom(ptr: *int) -> int { *ptr } ~~~~"
msgstr ""
"~~~~\n"
"let square = |x: int| -> uint { (x * x) as uint };\n"
"~~~~~~~~\n"
#. type: Plain text
#: doc/guide-ffi.md:344
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~{.xfail-test} use std::libc;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-ffi.md:363
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~{.xfail-test} use std::libc; use std::ptr;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"

View File

@ -0,0 +1,315 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-lifetimes.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust References and Lifetimes Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-lifetimes.md:26
#, fuzzy
#| msgid "## A minimal example"
msgid "# By example"
msgstr "## 最小限の例"
#. type: Plain text
#: doc/guide-lifetimes.md:33
#, fuzzy
#| msgid "As an example, consider a simple struct type, `Point`:"
msgid "As an example, consider a simple struct type `Point`:"
msgstr "例として、シンプルな構造体型の `Point` について考えます。"
#. type: Plain text
#: doc/guide-lifetimes.md:41
#, fuzzy
#| msgid ""
#| "We can use this simple definition to allocate points in many different "
#| "ways. For example, in this code, each of these three local variables "
#| "contains a point, but allocated in a different location:"
msgid ""
"We can use this simple definition to allocate points in many different ways. "
"For example, in this code, each of these three local variables contains a "
"point, but allocated in a different place:"
msgstr ""
"シンプルな定義ですが、この定義を使って `Point` 型のオブジェクトを様々な方法で"
"割り当てることができます。例えば、このコードの3つのローカル変数は、それぞれ異"
"なった場所に `Point` 型のオブジェクトを割り当てています。"
#. type: Plain text
#: doc/guide-lifetimes.md:48
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"~~~\n"
"# struct Point {x: f64, y: f64}\n"
"let on_the_stack : Point = Point {x: 3.0, y: 4.0};\n"
"let managed_box : @Point = @Point {x: 5.0, y: 1.0};\n"
"let owned_box : ~Point = ~Point {x: 7.0, y: 9.0};\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-lifetimes.md:60
#, fuzzy
#| msgid ""
#| "Suppose we want to write a procedure that computes the distance between "
#| "any two points, no matter where they are stored. For example, we might "
#| "like to compute the distance between `on_the_stack` and `managed_box`, or "
#| "between `managed_box` and `owned_box`. One option is to define a function "
#| "that takes two arguments of type point—that is, it takes the points by "
#| "value. But this will cause the points to be copied when we call the "
#| "function. For points, this is probably not so bad, but often copies are "
#| "expensive. So wed like to define a function that takes the points by "
#| "pointer. We can use borrowed pointers to do this:"
msgid ""
"Suppose we wanted to write a procedure that computed the distance between "
"any two points, no matter where they were stored. For example, we might like "
"to compute the distance between `on_the_stack` and `managed_box`, or between "
"`managed_box` and `owned_box`. One option is to define a function that takes "
"two arguments of type `Point`—that is, it takes the points by value. But if "
"we define it this way, calling the function will cause the points to be "
"copied. For points, this is probably not so bad, but often copies are "
"expensive. Worse, if the data type contains mutable fields, copying can "
"change the semantics of your program in unexpected ways. So we'd like to "
"define a function that takes the points by pointer. We can use references to "
"do this:"
msgstr ""
"`Point` 型のオブジェクトの割り当て先がどこであったとしても利用可能な、任意の "
"2 点間の距離を計算する処理を書きたいとします。例えば、 `on_the_stack`, "
"`managed_box` 間や `managed_box`, `owned_box` 間の距離を計算する処理です。 1"
"つ目の実装方法として、2つの `Point` 型オブジェクトを引数にとる関数を定義する"
"方法、すなわち、オブジェクトを値で受け渡す方法があります。しかし、この方法で"
"は関数呼び出し時に `Point` オブジェクトのコピーが行われます。`Point` オブジェ"
"クトの場合、このような実装はそれほど悪いものではないでしょうが、コピー処理の"
"コストは高い場合もあります。したがって、`Point` オブジェクトをポインタ渡しす"
"る関数を定義する必要があります。そのために、借用ポインタを利用することが可能"
"です。"
#. type: Plain text
#: doc/guide-lifetimes.md:72 doc/tutorial.md:1394
msgid "Now we can call `compute_distance()` in various ways:"
msgstr ""
"上記の `compute_distance()` 関数は、様々な方法で呼び出すことができます。"
#. type: Plain text
#: doc/guide-lifetimes.md:82
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"~~~\n"
"# struct Point {x: f64, y: f64}\n"
"# let on_the_stack : Point = Point{x: 3.0, y: 4.0};\n"
"# let managed_box : @Point = @Point{x: 5.0, y: 1.0};\n"
"# let owned_box : ~Point = ~Point{x: 7.0, y: 9.0};\n"
"# fn compute_distance(p1: &Point, p2: &Point) -> f64 { 0.0 }\n"
"compute_distance(&on_the_stack, managed_box);\n"
"compute_distance(managed_box, owned_box);\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-lifetimes.md:89
#, fuzzy
#| msgid ""
#| "Here the `&` operator is used to take the address of the variable "
#| "`on_the_stack`; this is because `on_the_stack` has the type `Point` (that "
#| "is, a struct value) and we have to take its address to get a value. We "
#| "also call this _borrowing_ the local variable `on_the_stack`, because we "
#| "are creating an alias: that is, another route to the same data."
msgid ""
"Here, the `&` operator takes the address of the variable `on_the_stack`; "
"this is because `on_the_stack` has the type `Point` (that is, a struct "
"value) and we have to take its address to get a value. We also call this "
"_borrowing_ the local variable `on_the_stack`, because we have created an "
"alias: that is, another name for the same data."
msgstr ""
"ここで `&` 演算子は `on_the_stack` 変数のアドレスを取得するために使われていま"
"す。これは、 `on_the_stack` の型は `Point` (つまり、構造体の値) であり、呼び"
"出した関数から値を取得させるため、構造体のアドレスを渡す必要があるからです。"
"値の別名 (エイリアス)、すなわち、同じデータへアクセスするための別の方法を提供"
"するので、このような操作のことをローカル変数 `on_the_stack` の __借用__ "
"(_borrowing_) と呼びます。"
#. type: Plain text
#: doc/guide-lifetimes.md:95
#, fuzzy
#| msgid ""
#| "In the case of the boxes `managed_box` and `owned_box`, however, no "
#| "explicit action is necessary. The compiler will automatically convert a "
#| "box like `@point` or `~point` to a borrowed pointer like `&point`. This "
#| "is another form of borrowing; in this case, the contents of the managed/"
#| "owned box are being lent out."
msgid ""
"In contrast, we can pass the boxes `managed_box` and `owned_box` to "
"`compute_distance` directly. The compiler automatically converts a box like "
"`@Point` or `~Point` to a reference like `&Point`. This is another form of "
"borrowing: in this case, the caller lends the contents of the managed or "
"owned box to the callee."
msgstr ""
"ボックスである `managed_box` と `owned_box` の場合は、特に明示的な操作を行う"
"必要はありません。コンパイラは `@point` や `~point` のようなボックスを自動的"
"に `&point` のような借用ポインタへと変換します。これは、別の形態の借用 "
"(borrowing) です。この場合、マネージド/所有ボックスの内容が貸し出されていま"
"す。"
#. type: Plain text
#: doc/guide-lifetimes.md:105
#, fuzzy
#| msgid ""
#| "Whenever a value is borrowed, there are some limitations on what you can "
#| "do with the original. For example, if the contents of a variable have "
#| "been lent out, you cannot send that variable to another task, nor will "
#| "you be permitted to take actions that might cause the borrowed value to "
#| "be freed or to change its type. This rule should make intuitive sense: "
#| "you must wait for a borrowed value to be returned (that is, for the "
#| "borrowed pointer to go out of scope) before you can make full use of it "
#| "again."
msgid ""
"Whenever a caller lends data to a callee, there are some limitations on what "
"the caller can do with the original. For example, if the contents of a "
"variable have been lent out, you cannot send that variable to another task. "
"In addition, the compiler will reject any code that might cause the borrowed "
"value to be freed or overwrite its component fields with values of different "
"types (I'll get into what kinds of actions those are shortly). This rule "
"should make intuitive sense: you must wait for a borrower to return the "
"value that you lent it (that is, wait for the reference to go out of scope) "
"before you can make full use of it again."
msgstr ""
"値が借用されている間、借用元の値に対して行える操作がいくらか制限されます。例"
"えば、変数の内容が貸し出された場合、その変数を他のタスクに送信することはでき"
"ませんし、借用された値を解放したり、型が変化させるような操作も行うことができ"
"ません。このルールは理にかなったものでしょう。貸し出した値を最大限に活用する "
"(make full use of it) ためには、貸し出した値の返却 (借用ポインタが存在するス"
"コープを抜ける) を待たなければなりません。"
#. type: Plain text
#: doc/guide-lifetimes.md:114
#, fuzzy
#| msgid ""
#| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: "
#| "20f }; println(fmt!(\"%f\", point.x)); ~~~"
msgid ""
"~~~ # struct Point {x: f64, y: f64} let on_the_stack: Point = Point {x: 3.0, "
"y: 4.0}; ~~~"
msgstr ""
"~~~\n"
"# struct Point { x: f64, y: f64 }\n"
"let point = &@~Point { x: 10f, y: 20f };\n"
"println(fmt!(\"%f\", point.x));\n"
"~~~"
#. type: Plain text
#: doc/guide-lifetimes.md:124
#, fuzzy
#| msgid ""
#| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: "
#| "20f }; println(fmt!(\"%f\", point.x)); ~~~"
msgid ""
"~~~ # struct Point {x: f64, y: f64} let on_the_stack2: &Point = &Point {x: "
"3.0, y: 4.0}; ~~~"
msgstr ""
"~~~\n"
"# struct Point { x: f64, y: f64 }\n"
"let point = &@~Point { x: 10f, y: 20f };\n"
"println(fmt!(\"%f\", point.x));\n"
"~~~"
#. type: Plain text
#: doc/guide-lifetimes.md:134
#, fuzzy
#| msgid ""
#| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: "
#| "20f }; println(fmt!(\"%f\", point.x)); ~~~"
msgid ""
"~~~ # struct Point {x: f64, y: f64} let tmp = Point {x: 3.0, y: 4.0}; let "
"on_the_stack2 : &Point = &tmp; ~~~"
msgstr ""
"~~~\n"
"# struct Point { x: f64, y: f64 }\n"
"let point = &@~Point { x: 10f, y: 20f };\n"
"println(fmt!(\"%f\", point.x));\n"
"~~~"
#. type: Plain text
#: doc/guide-lifetimes.md:180
#, fuzzy
#| msgid "# Borrowed pointers"
msgid "# Borrowing managed boxes and rooting"
msgstr "# 借用ポインタ"
#. type: Plain text
#: doc/guide-lifetimes.md:262
#, fuzzy
#| msgid "# Borrowed pointers"
msgid "# Borrowing owned boxes"
msgstr "# 借用ポインタ"
#. type: Plain text
#: doc/guide-lifetimes.md:367
#, fuzzy
#| msgid "# Borrowed pointers"
msgid "# Borrowing and enums"
msgstr "# 借用ポインタ"
#. type: Plain text
#: doc/guide-lifetimes.md:477
#, fuzzy
#| msgid "# Dereferencing pointers"
msgid "# Returning references"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/guide-lifetimes.md:490
#, fuzzy
#| msgid ""
#| "~~~ # struct Point { x: f64, y: f64 } let point = &@~Point { x: 10f, y: "
#| "20f }; println(fmt!(\"%f\", point.x)); ~~~"
msgid ""
"~~~ struct Point {x: f64, y: f64} fn get_x<'r>(p: &'r Point) -> &'r f64 { &p."
"x } ~~~"
msgstr ""
"~~~\n"
"# struct Point { x: f64, y: f64 }\n"
"let point = &@~Point { x: 10f, y: 20f };\n"
"println(fmt!(\"%f\", point.x));\n"
"~~~"
#. type: Plain text
#: doc/guide-lifetimes.md:659
#, fuzzy
#| msgid "## Conventions"
msgid "# Conclusion"
msgstr "## 本書の表記について"

View File

@ -0,0 +1,94 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-macros.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Macros Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-macros.md:67
#, fuzzy
#| msgid "## Do syntax"
msgid "# Invocation syntax"
msgstr "## do 構文"
#. type: Plain text
#: doc/guide-macros.md:100
#, fuzzy
#| msgid "# Introduction"
msgid "## Invocation location"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-macros.md:115
#, fuzzy
#| msgid "## Traits"
msgid "# Transcription syntax"
msgstr "## トレイト"
#. type: Plain text
#: doc/guide-macros.md:135
#, fuzzy
#| msgid "# Introduction"
msgid "## Interpolation location"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-macros.md:143
#, fuzzy
#| msgid "# Introduction"
msgid "## Invocation"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-macros.md:181
#, fuzzy
#| msgid "## Traits"
msgid "### Transcription"
msgstr "## トレイト"
#. type: Plain text
#: doc/guide-macros.md:193
#, fuzzy
#| msgid "## Pattern matching"
msgid "## Parsing limitations"
msgstr "## パターンマッチ"
#. type: Plain text
#: doc/guide-macros.md:212
#, fuzzy
#| msgid "## Pattern matching"
msgid "# Macro argument pattern matching"
msgstr "## パターンマッチ"
#. type: Plain text
#: doc/guide-macros.md:214
#, fuzzy
#| msgid "## Conventions"
msgid "## Motivation"
msgstr "## 本書の表記について"

View File

@ -0,0 +1,292 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-pointers.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Pointer Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-pointers.md:21
#, fuzzy
#| msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
msgid "~~~rust fn succ(x: &int) -> int { *x + 1 } ~~~"
msgstr ""
"~~~~\n"
"let square = |x: int| -> uint { (x * x) as uint };\n"
"~~~~~~~~\n"
#. type: Plain text
#: doc/guide-pointers.md:58
#, fuzzy
#| msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
msgid "~~~rust fn succ(x: int) -> int { x + 1 }"
msgstr ""
"~~~~\n"
"let square = |x: int| -> uint { (x * x) as uint };\n"
"~~~~~~~~\n"
#. type: Plain text
#: doc/guide-pointers.md:115
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let p0 = Point { x: 5, y: 10};\n"
" let p1 = transform(p0);\n"
" println!(\"{:?}\", p1);\n"
"}\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:129
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"~~~rust\n"
"# struct Point {\n"
"# x: int,\n"
"# y: int,\n"
"# }\n"
"# let p0 = Point { x: 5, y: 10};\n"
"fn transform(p: &Point) -> Point {\n"
" Point { x: p.x + 1, y: p.y + 1}\n"
"}\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:145
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn transform(p: Point) -> Point {\n"
" Point { x: p.x + 1, y: p.y + 1}\n"
"}\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:152
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let p0 = Point { x: 5, y: 10};\n"
" let p1 = transform(p0);\n"
" println!(\"{:?}\", p1);\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:162
#, fuzzy
#| msgid "# Borrowed pointers"
msgid "# Owned Pointers"
msgstr "# 借用ポインタ"
#. type: Plain text
#: doc/guide-pointers.md:175
#, fuzzy
msgid "## References to Traits"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/guide-pointers.md:181
#, fuzzy
#| msgid "# Data structures"
msgid "## Recursive Data Structures"
msgstr "# データ構造"
#. type: Plain text
#: doc/guide-pointers.md:229
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let a = Point { x: 10, y: 20 };\n"
" do spawn {\n"
" println!(\"{}\", a.x);\n"
" }\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:246
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let a = ~Point { x: 10, y: 20 };\n"
" do spawn {\n"
" println!(\"{}\", a.x);\n"
" }\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:251
#, fuzzy
#| msgid "## Managed boxes"
msgid "# Managed Pointers"
msgstr "## マネージドボックス"
#. type: Plain text
#: doc/guide-pointers.md:277
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let a = ~Point { x: 10, y: 20 };\n"
" let b = a;\n"
" println!(\"{}\", b.x);\n"
" println!(\"{}\", a.x);\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:308
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let a = @Point { x: 10, y: 20 };\n"
" let b = a;\n"
" println!(\"{}\", b.x);\n"
" println!(\"{}\", a.x);\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:326 doc/tutorial.md:1345
#, fuzzy
msgid "# References"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/guide-pointers.md:336
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~rust use std::num::sqrt;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-pointers.md:352
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} # struct Point { x: f64, y: f64 } let mut mypoint = Point { x: 1.0, y: 1.0 }; let origin = Point { x: 0.0, y: 0.0 };"
msgid ""
"fn main() {\n"
" let origin = @Point { x: 0.0, y: 0.0 };\n"
" let p1 = ~Point { x: 5.0, y: 3.0 };\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"# struct Point { x: f64, y: f64 }\n"
"let mut mypoint = Point { x: 1.0, y: 1.0 };\n"
"let origin = Point { x: 0.0, y: 0.0 };"
#. type: Plain text
#: doc/guide-pointers.md:378
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} // main.rs extern mod world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid ""
"~~~rust{.xfail-test}\n"
"fn main() {\n"
" println!(\"{}\", x);\n"
" let x = 5;\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"// main.rs\n"
"extern mod world;\n"
"fn main() { println(~\"hello \" + world::explore()); }\n"
"~~~~"
#. type: Plain text
#: doc/guide-pointers.md:433
#, fuzzy
#| msgid "# Dereferencing pointers"
msgid "# Returning Pointers"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/guide-pointers.md:444
#, fuzzy, no-wrap
#| msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
msgid ""
"~~~rust\n"
"fn foo(x: ~int) -> ~int {\n"
" return ~*x;\n"
"}\n"
msgstr ""
"~~~~\n"
"let square = |x: int| -> uint { (x * x) as uint };\n"
"~~~~~~~~\n"
#. type: Plain text
#: doc/guide-pointers.md:457 doc/guide-pointers.md:471
#, fuzzy, no-wrap
#| msgid "~~~~ let square = |x: int| -> uint { (x * x) as uint }; ~~~~"
msgid ""
"~~~rust\n"
"fn foo(x: ~int) -> int {\n"
" return *x;\n"
"}\n"
msgstr ""
"~~~~\n"
"let square = |x: int| -> uint { (x * x) as uint };\n"
"~~~~~~~~\n"

View File

@ -0,0 +1,112 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-rustpkg.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Packaging Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-rustpkg.md:11
#, fuzzy
#| msgid "## Using other crates"
msgid "# Installing External Packages"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/guide-rustpkg.md:22
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} // main.rs extern mod world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid ""
"fn main() {\n"
" hello::world();\n"
"}\n"
"~~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"// main.rs\n"
"extern mod world;\n"
"fn main() { println(~\"hello \" + world::explore()); }\n"
"~~~~"
#. type: Plain text
#: doc/guide-rustpkg.md:91
#, fuzzy
#| msgid "## Using other crates"
msgid "# Building your own Package"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/guide-rustpkg.md:98
#, fuzzy
#| msgid "## Using other crates"
msgid "## Creating our workspace"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/guide-rustpkg.md:115
#, fuzzy
#| msgid "# Introduction"
msgid "## Installation"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-rustpkg.md:149
#, fuzzy, no-wrap
#| msgid "~~~~ {.xfail-test} // main.rs extern mod world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid ""
"pub fn world() {\n"
" println!(\"Hello, world.\");\n"
"}\n"
"~~~\n"
msgstr ""
"~~~~ {.xfail-test}\n"
"// main.rs\n"
"extern mod world;\n"
"fn main() { println(~\"hello \" + world::explore()); }\n"
"~~~~"
#. type: Plain text
#: doc/guide-rustpkg.md:161
#, fuzzy
#| msgid "## Using other crates"
msgid "## Building your package"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/guide-rustpkg.md:209
#, fuzzy
#| msgid "## Using other crates"
msgid "# Testing your Package"
msgstr "## 他のクレートの利用"
#. type: Plain text
#: doc/guide-rustpkg.md:257
#, fuzzy
#| msgid "## Managed boxes"
msgid "# More resources"
msgstr "## マネージドボックス"

View File

@ -0,0 +1,81 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/guide-tasks.md:2
#, fuzzy
#| msgid "[Tasks and communication][tasks]"
msgid "% The Rust Tasks and Communication Guide"
msgstr "[タスクと通信][tasks]"
#. type: Plain text
#: doc/guide-tasks.md:64
#, fuzzy
#| msgid "# Syntax basics"
msgid "# Basics"
msgstr "# 基本的な構文"
#. type: Plain text
#: doc/guide-tasks.md:73 doc/guide-tasks.md:132
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~~ # use std::task::spawn;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-tasks.md:113
#, fuzzy
#| msgid "## Conditionals"
msgid "## Communication"
msgstr "## 条件式"
#. type: Plain text
#: doc/guide-tasks.md:214
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ # use std::task::spawn;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-tasks.md:246
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ # use std::task::spawn; # use std::vec;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-tasks.md:327
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ # use std::vec; # use std::rand; use extra::arc::Arc;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"

View File

@ -0,0 +1,75 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-testing.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% The Rust Testing Guide"
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/guide-testing.md:4
#, fuzzy
#| msgid "# Getting started"
msgid "# Quick start"
msgstr "# はじめに"
#. type: Plain text
#: doc/guide-testing.md:127 doc/tutorial.md:776
#, fuzzy
#| msgid "## A minimal example"
msgid "For example:"
msgstr "## 最小限の例"
#. type: Plain text
#: doc/guide-testing.md:131
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ extern mod extra; use std::vec;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
#. type: Plain text
#: doc/guide-testing.md:167
#, fuzzy
#| msgid "## Tuples"
msgid "## Examples"
msgstr "## タプル"
#. type: Plain text
#: doc/guide-testing.md:169
#, fuzzy
#| msgid "## Tuple structs"
msgid "### Typical test run"
msgstr "## タプル構造体"
#. type: Plain text
#: doc/guide-testing.md:197
#, fuzzy
#| msgid "# Dereferencing pointers"
msgid "### Running ignored tests"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/guide-testing.md:235
#, fuzzy
#| msgid "## Declaring and implementing traits"
msgid "## Saving and ratcheting metrics"
msgstr "## トレイトの宣言と実装"

31
doc/po/ja/index.md.po Normal file
View File

@ -0,0 +1,31 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-14 21:02+0900\n"
"PO-Revision-Date: 2014-01-14 21:02+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/index.md:2
#, fuzzy
#| msgid "## Using the rust tool"
msgid "% Rust documentation"
msgstr "## `rust` コマンドを利用する"
#. type: Plain text
#: doc/index.md:26
#, fuzzy
#| msgid "## Using other crates"
msgid "# Libraries"
msgstr "## 他のクレートの利用"

File diff suppressed because it is too large Load Diff

52
doc/po/ja/rustdoc.md.po Normal file
View File

@ -0,0 +1,52 @@
# Japanese translations for Rust package
# Copyright (C) 2014 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.10-pre\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/rustdoc.md:2
#, fuzzy
#| msgid "## Using the rust tool"
msgid "% Rust Documentation"
msgstr "## `rust` コマンドを利用する"
#. type: Plain text
#: doc/rustdoc.md:9
#, fuzzy
#| msgid "## Using the rust tool"
msgid "# Creating Documentation"
msgstr "## `rust` コマンドを利用する"
#. type: Plain text
#: doc/rustdoc.md:79
#, fuzzy
#| msgid "## Using the rust tool"
msgid "# Using the Documentation"
msgstr "## `rust` コマンドを利用する"
#. type: Plain text
#: doc/rustdoc.md:90
#, fuzzy
#| msgid "## Using the rust tool"
msgid "# Testing the Documentation"
msgstr "## `rust` コマンドを利用する"
#. type: Plain text
#: doc/rustdoc.md:102
#, fuzzy
#| msgid "# Dereferencing pointers"
msgid "## Defining tests"
msgstr "# ポインタのデリファレンス"

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.8\n"
"POT-Creation-Date: 2013-07-30 07:07+0900\n"
"POT-Creation-Date: 2014-01-13 12:01+0900\n"
"PO-Revision-Date: 2013-07-28 20:32+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
@ -17,307 +17,49 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/guide-conditions.md:4 doc/guide-ffi.md:4 doc/guide-lifetimes.md:4
#: doc/guide-macros.md:4 doc/guide-rustpkg.md:4 doc/guide-tasks.md:4
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
#: doc/tutorial-borrowed-ptr.md:4 doc/tutorial-ffi.md:4
#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/rust.md:30 doc/rustpkg.md:8
msgid "## Disclaimer"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:2
#, fuzzy
#| msgid "% The Rust Language Tutorial"
msgid "% Rustpkg Reference Manual"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:6
msgid ""
"This document is the reference manual for the Rustpkg packaging and build "
"tool for the Rust programming language."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:12
msgid ""
"Rustpkg is a work in progress, as is this reference manual. If the actual "
"behavior of rustpkg differs from the behavior described in this reference, "
"that reflects either an incompleteness or a bug in rustpkg."
msgstr ""
msgstr "% Rust 言語チュートリアル"
#. type: Plain text
#: doc/rustpkg.md:14
#, fuzzy
#| msgid "## Pattern matching"
msgid "# Package searching"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:17
msgid ""
"rustpkg searches for packages using the `RUST_PATH` environment variable, "
"which is a colon-separated list (semicolon-separated on Windows) of "
"directories."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:19
msgid "Each directory in this list is a *workspace* for rustpkg."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:30
msgid ""
"`RUST_PATH` implicitly contains an entry for `./.rust` (as well as `../."
"rust`, `../../.rust`, and so on for every parent of `.` up to the filesystem "
"root). That means that if `RUST_PATH` is not set, then rustpkg will still "
"search for workspaces in `./.rust` and so on. `RUST_PATH` also implicitly "
"contains an entry for the system path: `/usr/local` or the equivalent on "
"Windows. This entry comes after the implicit entries for `./.rust` and so "
"on. Finally, the last implicit entry in `RUST_PATH` is `~/.rust` or the "
"equivalent on Windows."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:32
msgid "Each workspace may contain one or more packages."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:38
msgid ""
"When building code that contains one or more directives of the form `extern "
"mod P`, rustpkg automatically searches for packages named `P` in the "
"`RUST_PATH` (as described above). It builds those dependencies if "
"necessary. Thus, when using rustpkg, there is no need for `-L` flags to "
"tell the linker where to find libraries for external crates."
msgstr ""
msgstr "## パターンマッチ"
#. type: Plain text
#: doc/rustpkg.md:40
#, fuzzy
#| msgid "# Data structures"
msgid "# Package structure"
msgstr ""
msgstr "# データ構造"
#. type: Plain text
#: doc/rustpkg.md:42
msgid "A valid workspace must contain each of the following subdirectories:"
msgstr ""
#. type: Bullet: '* '
#: doc/rustpkg.md:44
msgid ""
"'src/': contains one subdirectory per package. Each subdirectory contains "
"source files for a given package."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:49
#, no-wrap
msgid ""
" For example, if `foo` is a workspace containing the package `bar`,\n"
" then `foo/src/bar/main.rs` could be the `main` entry point for\n"
" building a `bar` executable.\n"
"* 'lib/': `rustpkg install` installs libraries into a target-specific subdirectory of this directory.\n"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:56
#, no-wrap
msgid ""
" For example, on a 64-bit machine running Mac OS X,\n"
" if `foo` is a workspace containing the package `bar`,\n"
" rustpkg will install libraries for bar to `foo/lib/x86_64-apple-darwin/`.\n"
" The libraries will have names of the form `foo/lib/x86_64-apple-darwin/libbar-[hash].dylib`,\n"
" where [hash] is a hash of the package ID.\n"
"* 'bin/': `rustpkg install` installs executable binaries into a target-specific subdirectory of this directory.\n"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:63
#, no-wrap
msgid ""
" For example, on a 64-bit machine running Mac OS X,\n"
" if `foo` is a workspace, containing the package `bar`,\n"
" rustpkg will install executables for `bar` to\n"
" `foo/bin/x86_64-apple-darwin/`.\n"
" The executables will have names of the form `foo/bin/x86_64-apple-darwin/bar`.\n"
"* 'build/': `rustpkg build` stores temporary build artifacts in a target-specific subdirectory of this directory.\n"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:67
#, no-wrap
msgid ""
" For example, on a 64-bit machine running Mac OS X,\n"
" if `foo` is a workspace containing the package `bar` and `foo/src/bar/main.rs` exists,\n"
" then `rustpkg build` will create `foo/build/x86_64-apple-darwin/bar/main.o`.\n"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:69
msgid "# Package identifiers"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:87
msgid ""
"A package identifier identifies a package uniquely. A package can be stored "
"in a workspace on the local file system, or on a remote Web server, in which "
"case the package ID resembles a URL. For example, `github.com/mozilla/rust` "
"is a package ID that would refer to the git repository browsable at `http://"
"github.com/mozilla/rust`. A package ID can also specify a version, like: "
"`github.com/mozilla/rust#0.3`. In this case, `rustpkg` will check that the "
"repository `github.com/mozilla/rust` has a tag named `0.3`, and report an "
"error otherwise. A package ID can also specify a particular revision of a "
"repository, like: `github.com/mozilla/rust#release-0.7`. When the refspec "
"(portion of the package ID after the `#`) can't be parsed as a decimal "
"number, rustpkg passes the refspec along to the version control system "
"without interpreting it. rustpkg also interprets any dependencies on such a "
"package ID literally (as opposed to versions, where a newer version "
"satisfies a dependency on an older version). Thus, `github.com/mozilla/"
"rust#5c4cd30f80` is also a valid package ID, since git can deduce that "
"5c4cd30f80 refers to a revision of the desired repository."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:89
msgid "## Source files"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:91
msgid ""
"rustpkg searches for four different fixed filenames in order to determine "
"the crates to build:"
msgstr ""
#. type: Bullet: '* '
#: doc/rustpkg.md:96
msgid "`main.rs`: Assumed to be a main entry point for building an executable."
msgstr ""
#. type: Bullet: '* '
#: doc/rustpkg.md:96
msgid "`lib.rs`: Assumed to be a library crate."
msgstr ""
#. type: Bullet: '* '
#: doc/rustpkg.md:96
msgid ""
"`test.rs`: Assumed to contain tests declared with the `#[test]` attribute."
msgstr ""
#. type: Bullet: '* '
#: doc/rustpkg.md:96
msgid ""
"`bench.rs`: Assumed to contain benchmarks declared with the `#[bench]` "
"attribute."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:98
#: doc/rustpkg.md:106
#, fuzzy
#| msgid "## Conventions"
msgid "## Versions"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:105
msgid ""
"`rustpkg` packages do not need to declare their versions with an attribute "
"inside one of the source files, because `rustpkg` infers it from the version "
"control system. When building a package that is in a `git` repository, "
"`rustpkg` assumes that the most recent tag specifies the current version. "
"When building a package that is not under version control, or that has no "
"tags, `rustpkg` assumes the intended version is 0.1."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:107
msgid "# Dependencies"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:111
msgid ""
"rustpkg infers dependencies from `extern mod` directives. Thus, there "
"should be no need to pass a `-L` flag to rustpkg to tell it where to find a "
"library. (In the future, it will also be possible to write an `extern mod` "
"directive referring to a remote package.)"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:113
msgid "# Custom build scripts"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:117
msgid ""
"A file called `pkg.rs` at the root level in a workspace is called a *package "
"script*. If a package script exists, rustpkg executes it to build the "
"package rather than inferring crates as described previously."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:121
msgid ""
"Inside `pkg.rs`, it's possible to call back into rustpkg to finish up the "
"build. `rustpkg::api` contains functions to build, install, or clean "
"libraries and executables in the way rustpkg normally would without custom "
"build logic."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:123
msgid "# Command reference"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:125
msgid "## build"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:131
msgid ""
"`rustpkg build foo` searches for a package with ID `foo` and builds it in "
"any workspace(s) where it finds one. Supposing such packages are found in "
"workspaces X, Y, and Z, the command leaves behind files in `X`'s, `Y`'s, and "
"`Z`'s `build` directories, but not in their `lib` or `bin` directories."
msgstr ""
msgstr "## 本書の表記について"
#. type: Plain text
#: doc/rustpkg.md:133
msgid "## clean"
msgstr ""
#, fuzzy
msgid "# Command reference"
msgstr "# ポインタのデリファレンス"
#. type: Plain text
#: doc/rustpkg.md:135
msgid "`rustpkg clean foo` deletes the contents of `foo`'s `build` directory."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:137
#: doc/rustpkg.md:150
#, fuzzy
#| msgid "# Introduction"
msgid "## install"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:141
msgid ""
"`rustpkg install foo` builds the libraries and/or executables that are "
"targets for `foo`, and then installs them either into `foo`'s `lib` and "
"`bin` directories, or into the `lib` and `bin` subdirectories of the first "
"entry in `RUST_PATH`."
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:143
msgid "## test"
msgstr ""
#. type: Plain text
#: doc/rustpkg.md:145
msgid ""
"`rustpkg test foo` builds `foo`'s `test.rs` file if necessary, then runs the "
"resulting test executable."
msgstr ""
msgstr "# イントロダクション"

File diff suppressed because it is too large Load Diff

View File

@ -1,673 +0,0 @@
# Japanese translations for Rust package
# Copyright (C) 2013 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.8\n"
"POT-Creation-Date: 2013-08-05 19:40+0900\n"
"PO-Revision-Date: 2013-07-28 20:32+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/tutorial-container.md:2
msgid "% Containers and iterators"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:4
msgid "# Containers"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:6
msgid "The container traits are defined in the `std::container` module."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:8
msgid "## Unique and managed vectors"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:12
msgid ""
"Vectors have `O(1)` indexing and removal from the end, along with `O(1)` "
"amortized insertion. Vectors are the most common container in Rust, and are "
"flexible enough to fit many use cases."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:16
msgid ""
"Vectors can also be sorted and used as efficient lookup tables with the "
"`std::vec::bsearch` function, if all the elements are inserted at one time "
"and deletions are unnecessary."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:18
msgid "## Maps and sets"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:22
msgid ""
"Maps are collections of unique keys with corresponding values, and sets are "
"just unique keys without a corresponding value. The `Map` and `Set` traits "
"in `std::container` define the basic interface."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:24
msgid "The standard library provides three owned map/set types:"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:30
msgid ""
"`std::hashmap::HashMap` and `std::hashmap::HashSet`, requiring the keys to "
"implement `Eq` and `Hash`"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:30
msgid ""
"`std::trie::TrieMap` and `std::trie::TrieSet`, requiring the keys to be "
"`uint`"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:30
msgid ""
"`extra::treemap::TreeMap` and `extra::treemap::TreeSet`, requiring the keys "
"to implement `TotalOrd`"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:34
msgid ""
"These maps do not use managed pointers so they can be sent between tasks as "
"long as the key and value types are sendable. Neither the key or value type "
"has to be copyable."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:37
msgid ""
"The `TrieMap` and `TreeMap` maps are ordered, while `HashMap` uses an "
"arbitrary order."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:42
msgid ""
"Each `HashMap` instance has a random 128-bit key to use with a keyed hash, "
"making the order of a set of keys in a given hash table randomized. Rust "
"provides a [SipHash](https://131002.net/siphash/) implementation for any "
"type implementing the `IterBytes` trait."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:44
msgid "## Double-ended queues"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:49
msgid ""
"The `extra::deque` module implements a double-ended queue with `O(1)` "
"amortized inserts and removals from both ends of the container. It also has "
"`O(1)` indexing like a vector. The contained elements are not required to be "
"copyable, and the queue will be sendable if the contained type is sendable."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:51
msgid "## Priority queues"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:55
msgid ""
"The `extra::priority_queue` module implements a queue ordered by a key. The "
"contained elements are not required to be copyable, and the queue will be "
"sendable if the contained type is sendable."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:61
msgid ""
"Insertions have `O(log n)` time complexity and checking or popping the "
"largest element is `O(1)`. Converting a vector to a priority queue can be "
"done in-place, and has `O(n)` complexity. A priority queue can also be "
"converted to a sorted vector in-place, allowing it to be used for an `O(n "
"log n)` in-place heapsort."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:63
msgid "# Iterators"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:65
msgid "## Iteration protocol"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:69
msgid ""
"The iteration protocol is defined by the `Iterator` trait in the `std::"
"iterator` module. The minimal implementation of the trait is a `next` "
"method, yielding the next element from an iterator object:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:73
msgid "~~~ /// An infinite stream of zeroes struct ZeroStream;"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:80
#, no-wrap
msgid ""
"impl Iterator<int> for ZeroStream {\n"
" fn next(&mut self) -> Option<int> {\n"
" Some(0)\n"
" }\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:83
msgid ""
"Reaching the end of the iterator is signalled by returning `None` instead of "
"`Some(item)`:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:89 doc/tutorial-container.md:262
#, no-wrap
msgid ""
"~~~\n"
"/// A stream of N zeroes\n"
"struct ZeroStream {\n"
" priv remaining: uint\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:95
#, no-wrap
msgid ""
"impl ZeroStream {\n"
" fn new(n: uint) -> ZeroStream {\n"
" ZeroStream { remaining: n }\n"
" }\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:107 doc/tutorial-container.md:284
#, no-wrap
msgid ""
"impl Iterator<int> for ZeroStream {\n"
" fn next(&mut self) -> Option<int> {\n"
" if self.remaining == 0 {\n"
" None\n"
" } else {\n"
" self.remaining -= 1;\n"
" Some(0)\n"
" }\n"
" }\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:109
msgid "## Container iterators"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:112
msgid ""
"Containers implement iteration over the contained elements by returning an "
"iterator object. For example, vector slices several iterators available:"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:116
msgid "`iter()` and `rev_iter()`, for immutable references to the elements"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:116
msgid ""
"`mut_iter()` and `mut_rev_iter()`, for mutable references to the elements"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-container.md:116
msgid ""
"`consume_iter()` and `consume_rev_iter`, to move the elements out by-value"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:119
msgid ""
"A typical mutable container will implement at least `iter()`, `mut_iter()` "
"and `consume_iter()` along with the reverse variants if it maintains an "
"order."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:121
msgid "### Freezing"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:125
msgid ""
"Unlike most other languages with external iterators, Rust has no *iterator "
"invalidation*. As long an iterator is still in scope, the compiler will "
"prevent modification of the container through another handle."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:130
#, no-wrap
msgid ""
"~~~\n"
"let mut xs = [1, 2, 3];\n"
"{\n"
" let _it = xs.iter();\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:136
#, no-wrap
msgid ""
" // the vector is frozen for this scope, the compiler will statically\n"
" // prevent modification\n"
"}\n"
"// the vector becomes unfrozen again at the end of the scope\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:139
msgid ""
"These semantics are due to most container iterators being implemented with "
"`&` and `&mut`."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:141
msgid "## Iterator adaptors"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:145
msgid ""
"The `IteratorUtil` trait implements common algorithms as methods extending "
"every `Iterator` implementation. For example, the `fold` method will "
"accumulate the items yielded by an `Iterator` into a single value:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:151
msgid ""
"~~~ let xs = [1, 9, 2, 3, 14, 12]; let result = xs.iter().fold(0, |"
"accumulator, item| accumulator - *item); assert_eq!(result, -41); ~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:153
msgid ""
"Some adaptors return an adaptor object implementing the `Iterator` trait "
"itself:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:160
msgid ""
"~~~ let xs = [1, 9, 2, 3, 14, 12]; let ys = [5, 2, 1, 8]; let sum = xs."
"iter().chain_(ys.iter()).fold(0, |a, b| a + *b); assert_eq!(sum, 57); ~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:164
msgid ""
"Note that some adaptors like the `chain_` method above use a trailing "
"underscore to work around an issue with method resolve. The underscores will "
"be dropped when they become unnecessary."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:166
msgid "## For loops"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:168
msgid ""
"The `for` keyword can be used as sugar for iterating through any iterator:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:171
msgid "~~~ let xs = [2, 3, 5, 7, 11, 13, 17];"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:176
#, no-wrap
msgid ""
"// print out all the elements in the vector\n"
"for x in xs.iter() {\n"
" println(x.to_str())\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:182
#, no-wrap
msgid ""
"// print out all but the first 3 elements in the vector\n"
"for x in xs.iter().skip(3) {\n"
" println(x.to_str())\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:185
msgid ""
"For loops are *often* used with a temporary iterator object, as above. They "
"can also advance the state of an iterator in a mutable location:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:189
msgid ""
"~~~ let xs = [1, 2, 3, 4, 5]; let ys = [\"foo\", \"bar\", \"baz\", \"foobar"
"\"];"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:192
msgid ""
"// create an iterator yielding tuples of elements from both vectors let mut "
"it = xs.iter().zip(ys.iter());"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:196
#, no-wrap
msgid ""
"// print out the pairs of elements up to (&3, &\"baz\")\n"
"for (x, y) in it {\n"
" printfln!(\"%d %s\", *x, *y);\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:201
#, no-wrap
msgid ""
" if *x == 3 {\n"
" break;\n"
" }\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:204
msgid ""
"// yield and print the last pair from the iterator printfln!(\"last: %?\", "
"it.next());"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:208
msgid "// the iterator is now fully consumed assert!(it.next().is_none()); ~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:210
msgid "## Conversion"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:212
msgid ""
"Iterators offer generic conversion to containers with the `collect` adaptor:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:218
msgid ""
"~~~ let xs = [0, 1, 1, 2, 3, 5, 8]; let ys = xs.rev_iter().skip(1)."
"transform(|&x| x * 2).collect::<~[int]>(); assert_eq!(ys, ~[10, 6, 4, 2, 2, "
"0]); ~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:221
msgid ""
"The method requires a type hint for the container type, if the surrounding "
"code does not provide sufficient information."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:225
msgid ""
"Containers can provide conversion from iterators through `collect` by "
"implementing the `FromIterator` trait. For example, the implementation for "
"vectors is as follows:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:238
#, no-wrap
msgid ""
"~~~\n"
"impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {\n"
" pub fn from_iterator(iterator: &mut T) -> ~[A] {\n"
" let (lower, _) = iterator.size_hint();\n"
" let mut xs = with_capacity(lower);\n"
" for x in iterator {\n"
" xs.push(x);\n"
" }\n"
" xs\n"
" }\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:240
msgid "### Size hints"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:243
msgid ""
"The `Iterator` trait provides a `size_hint` default method, returning a "
"lower bound and optionally on upper bound on the length of the iterator:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:247
msgid "~~~ fn size_hint(&self) -> (uint, Option<uint>) { (0, None) } ~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:251
msgid ""
"The vector implementation of `FromIterator` from above uses the lower bound "
"to pre-allocate enough space to hold the minimum number of elements the "
"iterator will yield."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:254
msgid ""
"The default implementation is always correct, but it should be overridden if "
"the iterator can provide better information."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:256
msgid ""
"The `ZeroStream` from earlier can provide an exact lower and upper bound:"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:267
#, no-wrap
msgid ""
"impl ZeroStream {\n"
" fn new(n: uint) -> ZeroStream {\n"
" ZeroStream { remaining: n }\n"
" }\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:272
#, no-wrap
msgid ""
" fn size_hint(&self) -> (uint, Option<uint>) {\n"
" (self.remaining, Some(self.remaining))\n"
" }\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:286
msgid "## Double-ended iterators"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:290
msgid ""
"The `DoubleEndedIterator` trait represents an iterator able to yield "
"elements from either end of a range. It inherits from the `Iterator` trait "
"and extends it with the `next_back` function."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:293
msgid ""
"A `DoubleEndedIterator` can be flipped with the `invert` adaptor, returning "
"another `DoubleEndedIterator` with `next` and `next_back` exchanged."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:300
msgid ""
"~~~ let xs = [1, 2, 3, 4, 5, 6]; let mut it = xs.iter(); printfln!(\"%?\", "
"it.next()); // prints `Some(&1)` printfln!(\"%?\", it.next()); // prints "
"`Some(&2)` printfln!(\"%?\", it.next_back()); // prints `Some(&6)`"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:306
#, no-wrap
msgid ""
"// prints `5`, `4` and `3`\n"
"for &x in it.invert() {\n"
" printfln!(\"%?\", x)\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:309
msgid ""
"The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted "
"version of the standard immutable and mutable vector iterators."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:312
msgid ""
"The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are "
"`DoubleEndedIterator` implementations if the underlying iterators are."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:317
msgid ""
"~~~ let xs = [1, 2, 3, 4]; let ys = [5, 6, 7, 8]; let mut it = xs.iter()."
"chain_(ys.iter()).transform(|&x| x * 2);"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:319
msgid "printfln!(\"%?\", it.next()); // prints `Some(2)`"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:325
#, no-wrap
msgid ""
"// prints `16`, `14`, `12`, `10`, `8`, `6`, `4`\n"
"for x in it.invert() {\n"
" printfln!(\"%?\", x);\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:327
msgid "## Random-access iterators"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:331
msgid ""
"The `RandomAccessIterator` trait represents an iterator offering random "
"access to the whole range. The `indexable` method retrieves the number of "
"elements accessible with the `idx` method."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:334
msgid ""
"The `chain_` adaptor is an implementation of `RandomAccessIterator` if the "
"underlying iterators are."
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:343
msgid ""
"~~~ let xs = [1, 2, 3, 4, 5]; let ys = ~[7, 9, 11]; let mut it = xs.iter()."
"chain_(ys.iter()); printfln!(\"%?\", it.idx(0)); // prints `Some(&1)` "
"printfln!(\"%?\", it.idx(5)); // prints `Some(&7)` printfln!(\"%?\", it."
"idx(7)); // prints `Some(&11)` printfln!(\"%?\", it.idx(8)); // prints `None`"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:348
msgid ""
"// yield two elements from the beginning, and one from the end it.next(); it."
"next(); it.next_back();"
msgstr ""
#. type: Plain text
#: doc/tutorial-container.md:352
msgid ""
"printfln!(\"%?\", it.idx(0)); // prints `Some(&3)` printfln!(\"%?\", it."
"idx(4)); // prints `Some(&9)` printfln!(\"%?\", it.idx(6)); // prints `None` "
"~~~"
msgstr ""

View File

@ -1,602 +0,0 @@
# Japanese translations for Rust package
# Copyright (C) 2013 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.8\n"
"POT-Creation-Date: 2013-08-10 07:44+0900\n"
"PO-Revision-Date: 2013-07-22 23:37+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
#: doc/tutorial-borrowed-ptr.md:4 doc/tutorial-ffi.md:4
#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/tutorial.md:868 doc/tutorial-ffi.md:143
msgid "# Destructors"
msgstr "# デストラクタ"
#. type: Plain text
#: doc/tutorial-ffi.md:2
msgid "% Rust Foreign Function Interface Tutorial"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:10
msgid ""
"This tutorial will use the [snappy](https://code.google.com/p/snappy/) "
"compression/decompression library as an introduction to writing bindings for "
"foreign code. Rust is currently unable to call directly into a C++ library, "
"but snappy includes a C interface (documented in [`snappy-c.h`](https://code."
"google.com/p/snappy/source/browse/trunk/snappy-c.h))."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:13
msgid ""
"The following is a minimal example of calling a foreign function which will "
"compile if snappy is installed:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:16
msgid "~~~~ {.xfail-test} use std::libc::size_t;"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:21
#, no-wrap
msgid ""
"#[link_args = \"-lsnappy\"]\n"
"extern {\n"
" fn snappy_max_compressed_length(source_length: size_t) -> size_t;\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:27
#, no-wrap
msgid ""
"fn main() {\n"
" let x = unsafe { snappy_max_compressed_length(100) };\n"
" println(fmt!(\"max compressed length of a 100 byte buffer: %?\", x));\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:31
msgid ""
"The `extern` block is a list of function signatures in a foreign library, in "
"this case with the platform's C ABI. The `#[link_args]` attribute is used to "
"instruct the linker to link against the snappy library so the symbols are "
"resolved."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:37
msgid ""
"Foreign functions are assumed to be unsafe so calls to them need to be "
"wrapped with `unsafe {}` as a promise to the compiler that everything "
"contained within truly is safe. C libraries often expose interfaces that "
"aren't thread-safe, and almost any function that takes a pointer argument "
"isn't valid for all possible inputs since the pointer could be dangling, and "
"raw pointers fall outside of Rust's safe memory model."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:41
msgid ""
"When declaring the argument types to a foreign function, the Rust compiler "
"will not check if the declaration is correct, so specifying it correctly is "
"part of keeping the binding correct at runtime."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:43
msgid "The `extern` block can be extended to cover the entire snappy API:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:46
msgid "~~~~ {.xfail-test} use std::libc::{c_int, size_t};"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:65
#, no-wrap
msgid ""
"#[link_args = \"-lsnappy\"]\n"
"extern {\n"
" fn snappy_compress(input: *u8,\n"
" input_length: size_t,\n"
" compressed: *mut u8,\n"
" compressed_length: *mut size_t) -> c_int;\n"
" fn snappy_uncompress(compressed: *u8,\n"
" compressed_length: size_t,\n"
" uncompressed: *mut u8,\n"
" uncompressed_length: *mut size_t) -> c_int;\n"
" fn snappy_max_compressed_length(source_length: size_t) -> size_t;\n"
" fn snappy_uncompressed_length(compressed: *u8,\n"
" compressed_length: size_t,\n"
" result: *mut size_t) -> c_int;\n"
" fn snappy_validate_compressed_buffer(compressed: *u8,\n"
" compressed_length: size_t) -> c_int;\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:67
msgid "# Creating a safe interface"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:71
msgid ""
"The raw C API needs to be wrapped to provide memory safety and make use of "
"higher-level concepts like vectors. A library can choose to expose only the "
"safe, high-level interface and hide the unsafe internal details."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:76
msgid ""
"Wrapping the functions which expect buffers involves using the `vec::raw` "
"module to manipulate Rust vectors as pointers to memory. Rust's vectors are "
"guaranteed to be a contiguous block of memory. The length is number of "
"elements currently contained, and the capacity is the total size in elements "
"of the allocated memory. The length is less than or equal to the capacity."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:84
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
"pub fn validate_compressed_buffer(src: &[u8]) -> bool {\n"
" unsafe {\n"
" snappy_validate_compressed_buffer(src.as_ptr(), src.len() as size_t) == 0\n"
" }\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:88
msgid ""
"The `validate_compressed_buffer` wrapper above makes use of an `unsafe` "
"block, but it makes the guarantee that calling it is safe for all inputs by "
"leaving off `unsafe` from the function signature."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:91
msgid ""
"The `snappy_compress` and `snappy_uncompress` functions are more complex, "
"since a buffer has to be allocated to hold the output too."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:96
msgid ""
"The `snappy_max_compressed_length` function can be used to allocate a vector "
"with the maximum required capacity to hold the compressed output. The vector "
"can then be passed to the `snappy_compress` function as an output parameter. "
"An output parameter is also passed to retrieve the true length after "
"compression for setting the length."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:102
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
"pub fn compress(src: &[u8]) -> ~[u8] {\n"
" unsafe {\n"
" let srclen = src.len() as size_t;\n"
" let psrc = src.as_ptr();\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:106
#, no-wrap
msgid ""
" let mut dstlen = snappy_max_compressed_length(srclen);\n"
" let mut dst = vec::with_capacity(dstlen as uint);\n"
" let pdst = dst.as_mut_ptr();\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:113
#, no-wrap
msgid ""
" snappy_compress(psrc, srclen, pdst, &mut dstlen);\n"
" dst.set_len(dstlen as uint);\n"
" dst\n"
" }\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:116
msgid ""
"Decompression is similar, because snappy stores the uncompressed size as "
"part of the compression format and `snappy_uncompressed_length` will "
"retrieve the exact buffer size required."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:122
#, no-wrap
msgid ""
"~~~~ {.xfail-test}\n"
"pub fn uncompress(src: &[u8]) -> Option<~[u8]> {\n"
" unsafe {\n"
" let srclen = src.len() as size_t;\n"
" let psrc = src.as_ptr();\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:125
#, no-wrap
msgid ""
" let mut dstlen: size_t = 0;\n"
" snappy_uncompressed_length(psrc, srclen, &mut dstlen);\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:128
#, no-wrap
msgid ""
" let mut dst = vec::with_capacity(dstlen as uint);\n"
" let pdst = dst.as_mut_ptr();\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:138
#, no-wrap
msgid ""
" if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {\n"
" dst.set_len(dstlen as uint);\n"
" Some(dst)\n"
" } else {\n"
" None // SNAPPY_INVALID_INPUT\n"
" }\n"
" }\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:141
msgid ""
"For reference, the examples used here are also available as an [library on "
"GitHub](https://github.com/thestinger/rust-snappy)."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:147
msgid ""
"Foreign libraries often hand off ownership of resources to the calling code, "
"which should be wrapped in a destructor to provide safety and guarantee "
"their release."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:150
msgid ""
"A type with the same functionality as owned boxes can be implemented by "
"wrapping `malloc` and `free`:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:156
msgid ""
"~~~~ use std::cast; use std::libc::{c_void, size_t, malloc, free}; use std::"
"ptr; use std::unstable::intrinsics;"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:161
#, no-wrap
msgid ""
"// a wrapper around the handle returned by the foreign code\n"
"pub struct Unique<T> {\n"
" priv ptr: *mut T\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:172
#, no-wrap
msgid ""
"impl<T: Send> Unique<T> {\n"
" pub fn new(value: T) -> Unique<T> {\n"
" unsafe {\n"
" let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;\n"
" assert!(!ptr::is_null(ptr));\n"
" // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it\n"
" intrinsics::move_val_init(&mut *ptr, value);\n"
" Unique{ptr: ptr}\n"
" }\n"
" }\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:177
#, no-wrap
msgid ""
" // the 'r lifetime results in the same semantics as `&*x` with ~T\n"
" pub fn borrow<'r>(&'r self) -> &'r T {\n"
" unsafe { cast::copy_lifetime(self, &*self.ptr) }\n"
" }\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:183
#, no-wrap
msgid ""
" // the 'r lifetime results in the same semantics as `&mut *x` with ~T\n"
" pub fn borrow_mut<'r>(&'r mut self) -> &'r mut T {\n"
" unsafe { cast::copy_mut_lifetime(self, &mut *self.ptr) }\n"
" }\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:195
#, no-wrap
msgid ""
"#[unsafe_destructor]\n"
"impl<T: Send> Drop for Unique<T> {\n"
" fn drop(&self) {\n"
" unsafe {\n"
" let x = intrinsics::init(); // dummy value to swap in\n"
" // moving the object out is needed to call the destructor\n"
" ptr::replace_ptr(self.ptr, x);\n"
" free(self.ptr as *c_void)\n"
" }\n"
" }\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:202
#, no-wrap
msgid ""
"// A comparison between the built-in ~ and this reimplementation\n"
"fn main() {\n"
" {\n"
" let mut x = ~5;\n"
" *x = 10;\n"
" } // `x` is freed here\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:209
#, no-wrap
msgid ""
" {\n"
" let mut y = Unique::new(5);\n"
" *y.borrow_mut() = 10;\n"
" } // `y` is freed here\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:211
msgid "# Linking"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:215
msgid ""
"In addition to the `#[link_args]` attribute for explicitly passing arguments "
"to the linker, an `extern mod` block will pass `-lmodname` to the linker by "
"default unless it has a `#[nolink]` attribute applied."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:217
msgid "# Unsafe blocks"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:221
msgid ""
"Some operations, like dereferencing unsafe pointers or calling functions "
"that have been marked unsafe are only allowed inside unsafe blocks. Unsafe "
"blocks isolate unsafety and are a promise to the compiler that the unsafety "
"does not leak out of the block."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:224
msgid ""
"Unsafe functions, on the other hand, advertise it to the world. An unsafe "
"function is written like this:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:228
msgid "~~~~ unsafe fn kaboom(ptr: *int) -> int { *ptr } ~~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:230
msgid ""
"This function can only be called from an `unsafe` block or another `unsafe` "
"function."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:232
msgid "# Accessing foreign globals"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:236
msgid ""
"Foreign APIs often export a global variable which could do something like "
"track global state. In order to access these variables, you declare them in "
"`extern` blocks with the `static` keyword:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:239
msgid "~~~{.xfail-test} use std::libc;"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:244
#, no-wrap
msgid ""
"#[link_args = \"-lreadline\"]\n"
"extern {\n"
" static rl_readline_version: libc::c_int;\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:250
#, no-wrap
msgid ""
"fn main() {\n"
" println(fmt!(\"You have readline version %d installed.\",\n"
" rl_readline_version as int));\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:254
msgid ""
"Alternatively, you may need to alter global state provided by a foreign "
"interface. To do this, statics can be declared with `mut` so rust can mutate "
"them."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:258
msgid "~~~{.xfail-test} use std::libc; use std::ptr;"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:263
#, no-wrap
msgid ""
"#[link_args = \"-lreadline\"]\n"
"extern {\n"
" static mut rl_prompt: *libc::c_char;\n"
"}\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:272
#, no-wrap
msgid ""
"fn main() {\n"
" do \"[my-awesome-shell] $\".as_c_str |buf| {\n"
" unsafe { rl_prompt = buf; }\n"
" // get a line, process it\n"
" unsafe { rl_prompt = ptr::null(); }\n"
" }\n"
"}\n"
"~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:274
msgid "# Foreign calling conventions"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:279
msgid ""
"Most foreign code exposes a C ABI, and Rust uses the platform's C calling "
"convention by default when calling foreign functions. Some foreign "
"functions, most notably the Windows API, use other calling conventions. Rust "
"provides the `abi` attribute as a way to hint to the compiler which calling "
"convention to use:"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:288
#, no-wrap
msgid ""
"~~~~\n"
"#[cfg(target_os = \"win32\")]\n"
"#[abi = \"stdcall\"]\n"
"#[link_name = \"kernel32\"]\n"
"extern {\n"
" fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;\n"
"}\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:292
msgid ""
"The `abi` attribute applies to a foreign module (it cannot be applied to a "
"single function within a module), and must be either `\"cdecl\"` or `"
"\"stdcall\"`. The compiler may eventually support other calling conventions."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:294
msgid "# Interoperability with foreign code"
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:298
msgid ""
"Rust guarantees that the layout of a `struct` is compatible with the "
"platform's representation in C. A `#[packed]` attribute is available, which "
"will lay out the struct members without padding. However, there are "
"currently no guarantees about the layout of an `enum`."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:305
msgid ""
"Rust's owned and managed boxes use non-nullable pointers as handles which "
"point to the contained object. However, they should not be manually created "
"because they are managed by internal allocators. Borrowed pointers can "
"safely be assumed to be non-nullable pointers directly to the type. However, "
"breaking the borrow checking or mutability rules is not guaranteed to be "
"safe, so prefer using raw pointers (`*`) if that's needed because the "
"compiler can't make as many assumptions about them."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:310
msgid ""
"Vectors and strings share the same basic memory layout, and utilities are "
"available in the `vec` and `str` modules for working with C APIs. Strings "
"are terminated with `\\0` for interoperability with C, but it should not be "
"assumed because a slice will not always be nul-terminated. Instead, the "
"`str::as_c_str` function should be used."
msgstr ""
#. type: Plain text
#: doc/tutorial-ffi.md:312
msgid ""
"The standard library includes type aliases and function definitions for the "
"C standard library in the `libc` module, and Rust links against `libc` and "
"`libm` by default."
msgstr ""

View File

@ -1,683 +0,0 @@
# Japanese translations for Rust package
# Copyright (C) 2013 The Rust Project Developers
# This file is distributed under the same license as the Rust package.
# Automatically generated, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: Rust 0.8\n"
"POT-Creation-Date: 2013-07-28 20:32+0900\n"
"PO-Revision-Date: 2013-07-28 20:32+0900\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. type: Plain text
#: doc/rust.md:4 doc/rustpkg.md:4 doc/tutorial.md:4
#: doc/tutorial-borrowed-ptr.md:4 doc/tutorial-ffi.md:4
#: doc/tutorial-macros.md:4 doc/tutorial-tasks.md:4
msgid "# Introduction"
msgstr "# イントロダクション"
#. type: Plain text
#: doc/rust.md:2136 doc/rust.md:2223 doc/tutorial-macros.md:323
msgid "~~~~"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:2
msgid "% Rust Macros Tutorial"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:12
msgid ""
"Functions are the primary tool that programmers can use to build "
"abstractions. Sometimes, however, programmers want to abstract over compile-"
"time syntax rather than run-time values. Macros provide syntactic "
"abstraction. For an example of how this can be useful, consider the "
"following two code fragments, which both pattern-match on their input and "
"both return early in one case, doing nothing otherwise:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:30
#, no-wrap
msgid ""
"~~~~\n"
"# enum t { special_a(uint), special_b(uint) };\n"
"# fn f() -> uint {\n"
"# let input_1 = special_a(0);\n"
"# let input_2 = special_a(0);\n"
"match input_1 {\n"
" special_a(x) => { return x; }\n"
" _ => {}\n"
"}\n"
"// ...\n"
"match input_2 {\n"
" special_b(x) => { return x; }\n"
" _ => {}\n"
"}\n"
"# return 0u;\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:38
msgid ""
"This code could become tiresome if repeated many times. However, no "
"function can capture its functionality to make it possible to abstract the "
"repetition away. Rust's macro system, however, can eliminate the "
"repetition. Macros are lightweight custom syntax extensions, themselves "
"defined using the `macro_rules!` syntax extension. The following "
"`early_return` macro captures the pattern in the above code:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:59
#, no-wrap
msgid ""
"~~~~\n"
"# enum t { special_a(uint), special_b(uint) };\n"
"# fn f() -> uint {\n"
"# let input_1 = special_a(0);\n"
"# let input_2 = special_a(0);\n"
"macro_rules! early_return(\n"
" ($inp:expr $sp:ident) => ( // invoke it like `(input_5 special_e)`\n"
" match $inp {\n"
" $sp(x) => { return x; }\n"
" _ => {}\n"
" }\n"
" );\n"
")\n"
"// ...\n"
"early_return!(input_1 special_a);\n"
"// ...\n"
"early_return!(input_2 special_b);\n"
"# return 0;\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:65
msgid ""
"Macros are defined in pattern-matching style: in the above example, the text "
"`($inp:expr $sp:ident)` that appears on the left-hand side of the `=>` is "
"the *macro invocation syntax*, a pattern denoting how to write a call to the "
"macro. The text on the right-hand side of the `=>`, beginning with `match "
"$inp`, is the *macro transcription syntax*: what the macro expands to."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:67
msgid "# Invocation syntax"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:71
msgid ""
"The macro invocation syntax specifies the syntax for the arguments to the "
"macro. It appears on the left-hand side of the `=>` in a macro definition. "
"It conforms to the following rules:"
msgstr ""
#. type: Bullet: '1. '
#: doc/tutorial-macros.md:76
msgid "It must be surrounded by parentheses."
msgstr ""
#. type: Bullet: '2. '
#: doc/tutorial-macros.md:76
msgid "`$` has special meaning (described below)."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:76
#, no-wrap
msgid ""
"3. The `()`s, `[]`s, and `{}`s it contains must balance. For example, `([)` is\n"
"forbidden.\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:78
msgid "Otherwise, the invocation syntax is free-form."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:83
#, no-wrap
msgid ""
"To take as an argument a fragment of Rust code, write `$` followed by a name\n"
" (for use on the right-hand side), followed by a `:`, followed by a *fragment\n"
" specifier*. The fragment specifier denotes the sort of fragment to match. The\n"
" most common fragment specifiers are:\n"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-macros.md:92
msgid ""
"`ident` (an identifier, referring to a variable or item. Examples: `f`, `x`, "
"`foo`.)"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-macros.md:92
msgid ""
"`expr` (an expression. Examples: `2 + 2`; `if true then { 1 } else { 2 }`; "
"`f(42)`.)"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-macros.md:92
msgid "`ty` (a type. Examples: `int`, `~[(char, ~str)]`, `&T`.)"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-macros.md:92
msgid ""
"`pat` (a pattern, usually appearing in a `match` or on the left-hand side of "
"a declaration. Examples: `Some(t)`; `(17, 'a')`; `_`.)"
msgstr ""
#. type: Bullet: '* '
#: doc/tutorial-macros.md:92
msgid ""
"`block` (a sequence of actions. Example: `{ log(error, \"hi\"); return 12; }"
"`)"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:95
msgid ""
"The parser interprets any token that's not preceded by a `$` literally. "
"Rust's usual rules of tokenization apply,"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:98
msgid ""
"So `($x:ident -> (($e:expr)))`, though excessively fancy, would designate a "
"macro that could be invoked like: `my_macro!(i->(( 2+2 )))`."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:100
msgid "## Invocation location"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:105
msgid ""
"A macro invocation may take the place of (and therefore expand to) an "
"expression, an item, or a statement. The Rust parser will parse the macro "
"invocation as a \"placeholder\" for whichever of those three nonterminals is "
"appropriate for the location."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:112
msgid ""
"At expansion time, the output of the macro will be parsed as whichever of "
"the three nonterminals it stands in for. This means that a single macro "
"might, for example, expand to an item or an expression, depending on its "
"arguments (and cause a syntax error if it is called with the wrong argument "
"for its location). Although this behavior sounds excessively dynamic, it is "
"known to be useful under some circumstances."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:115
msgid "# Transcription syntax"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:119
msgid ""
"The right-hand side of the `=>` follows the same rules as the left-hand "
"side, except that a `$` need only be followed by the name of the syntactic "
"fragment to transcribe into the macro expansion; its type need not be "
"repeated."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:126
msgid ""
"The right-hand side must be enclosed by delimiters, which the transcriber "
"ignores. Therefore `() => ((1,2,3))` is a macro that expands to a tuple "
"expression, `() => (let $x=$val)` is a macro that expands to a statement, "
"and `() => (1,2,3)` is a macro that expands to a syntax error (since the "
"transcriber interprets the parentheses on the right-hand-size as delimiters, "
"and `1,2,3` is not a valid Rust expression on its own)."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:133
msgid ""
"Except for permissibility of `$name` (and `$(...)*`, discussed below), the "
"right-hand side of a macro definition is ordinary Rust syntax. In "
"particular, macro invocations (including invocations of the macro currently "
"being defined) are permitted in expression, statement, and item locations. "
"However, nothing else about the code is examined or executed by the macro "
"system; execution still has to wait until run-time."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:135
msgid "## Interpolation location"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:139
msgid ""
"The interpolation `$argument_name` may appear in any location consistent "
"with its fragment specifier (i.e., if it is specified as `ident`, it may be "
"used anywhere an identifier is permitted)."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:141
msgid "# Multiplicity"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:143
msgid "## Invocation"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:150
msgid ""
"Going back to the motivating example, recall that `early_return` expanded "
"into a `match` that would `return` if the `match`'s scrutinee matched the "
"\"special case\" identifier provided as the second argument to "
"`early_return`, and do nothing otherwise. Now suppose that we wanted to "
"write a version of `early_return` that could handle a variable number of "
"\"special\" cases."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:156
msgid ""
"The syntax `$(...)*` on the left-hand side of the `=>` in a macro definition "
"accepts zero or more occurrences of its contents. It works much like the `*` "
"operator in regular expressions. It also supports a separator token (a comma-"
"separated list could be written `$(...),*`), and `+` instead of `*` to mean "
"\"at least one\"."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:179
#, no-wrap
msgid ""
"~~~~\n"
"# enum t { special_a(uint),special_b(uint),special_c(uint),special_d(uint)};\n"
"# fn f() -> uint {\n"
"# let input_1 = special_a(0);\n"
"# let input_2 = special_a(0);\n"
"macro_rules! early_return(\n"
" ($inp:expr, [ $($sp:ident)|+ ]) => (\n"
" match $inp {\n"
" $(\n"
" $sp(x) => { return x; }\n"
" )+\n"
" _ => {}\n"
" }\n"
" );\n"
")\n"
"// ...\n"
"early_return!(input_1, [special_a|special_c|special_d]);\n"
"// ...\n"
"early_return!(input_2, [special_b]);\n"
"# return 0;\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:181
msgid "### Transcription"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:191
msgid ""
"As the above example demonstrates, `$(...)*` is also valid on the right-hand "
"side of a macro definition. The behavior of `*` in transcription, especially "
"in cases where multiple `*`s are nested, and multiple different names are "
"involved, can seem somewhat magical and intuitive at first. The system that "
"interprets them is called \"Macro By Example\". The two rules to keep in "
"mind are (1) the behavior of `$(...)*` is to walk through one \"layer\" of "
"repetitions for all of the `$name`s it contains in lockstep, and (2) each `"
"$name` must be under at least as many `$(...)*`s as it was matched against. "
"If it is under more, it'll be repeated, as appropriate."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:193
msgid "## Parsing limitations"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:197
msgid ""
"For technical reasons, there are two limitations to the treatment of syntax "
"fragments by the macro parser:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:210
#, no-wrap
msgid ""
"1. The parser will always parse as much as possible of a Rust syntactic\n"
"fragment. For example, if the comma were omitted from the syntax of\n"
"`early_return!` above, `input_1 [` would've been interpreted as the beginning\n"
"of an array index. In fact, invoking the macro would have been impossible.\n"
"2. The parser must have eliminated all ambiguity by the time it reaches a\n"
"`$name:fragment_specifier` declaration. This limitation can result in parse\n"
"errors when declarations occur at the beginning of, or immediately after,\n"
"a `$(...)*`. For example, the grammar `$($t:ty)* $e:expr` will always fail to\n"
"parse because the parser would be forced to choose between parsing `t` and\n"
"parsing `e`. Changing the invocation syntax to require a distinctive token in\n"
"front can solve the problem. In the above example, `$(T $t:ty)* E $e:exp`\n"
"solves the problem.\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:212
msgid "# Macro argument pattern matching"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:214
msgid "Now consider code like the following:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:216
msgid "## Motivation"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:236
#, no-wrap
msgid ""
"~~~~\n"
"# enum t1 { good_1(t2, uint), bad_1 };\n"
"# pub struct t2 { body: t3 }\n"
"# enum t3 { good_2(uint), bad_2};\n"
"# fn f(x: t1) -> uint {\n"
"match x {\n"
" good_1(g1, val) => {\n"
" match g1.body {\n"
" good_2(result) => {\n"
" // complicated stuff goes here\n"
" return result + val;\n"
" },\n"
" _ => fail!(\"Didn't get good_2\")\n"
" }\n"
" }\n"
" _ => return 0 // default value\n"
"}\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:241
msgid ""
"All the complicated stuff is deeply indented, and the error-handling code is "
"separated from matches that fail. We'd like to write a macro that performs a "
"match, but with a syntax that suits the problem better. The following macro "
"can solve the problem:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:263
#, no-wrap
msgid ""
"~~~~\n"
"macro_rules! biased_match (\n"
" // special case: `let (x) = ...` is illegal, so use `let x = ...` instead\n"
" ( ($e:expr) ~ ($p:pat) else $err:stmt ;\n"
" binds $bind_res:ident\n"
" ) => (\n"
" let $bind_res = match $e {\n"
" $p => ( $bind_res ),\n"
" _ => { $err }\n"
" };\n"
" );\n"
" // more than one name; use a tuple\n"
" ( ($e:expr) ~ ($p:pat) else $err:stmt ;\n"
" binds $( $bind_res:ident ),*\n"
" ) => (\n"
" let ( $( $bind_res ),* ) = match $e {\n"
" $p => ( $( $bind_res ),* ),\n"
" _ => { $err }\n"
" };\n"
" )\n"
")\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:277
#, no-wrap
msgid ""
"# enum t1 { good_1(t2, uint), bad_1 };\n"
"# pub struct t2 { body: t3 }\n"
"# enum t3 { good_2(uint), bad_2};\n"
"# fn f(x: t1) -> uint {\n"
"biased_match!((x) ~ (good_1(g1, val)) else { return 0 };\n"
" binds g1, val )\n"
"biased_match!((g1.body) ~ (good_2(result) )\n"
" else { fail!(\"Didn't get good_2\") };\n"
" binds result )\n"
"// complicated stuff goes here\n"
"return result + val;\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:288
#, no-wrap
msgid ""
"This solves the indentation problem. But if we have a lot of chained matches\n"
"like this, we might prefer to write a single macro invocation. The input\n"
"pattern we want is clear:\n"
"~~~~\n"
"# macro_rules! b(\n"
" ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*\n"
" binds $( $bind_res:ident ),*\n"
" )\n"
"# => (0))\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:291
msgid ""
"However, it's not possible to directly expand to nested match statements. "
"But there is a solution."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:293
msgid "## The recursive approach to macro writing"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:297
msgid ""
"A macro may accept multiple different input grammars. The first one to "
"successfully match the actual argument to a macro invocation is the one that "
"\"wins\"."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:301
msgid ""
"In the case of the example above, we want to write a recursive macro to "
"process the semicolon-terminated lines, one-by-one. So, we want the "
"following input patterns:"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:308
#, no-wrap
msgid ""
"~~~~\n"
"# macro_rules! b(\n"
" ( binds $( $bind_res:ident ),* )\n"
"# => (0))\n"
"~~~~\n"
"...and:\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:317
#, no-wrap
msgid ""
"~~~~\n"
"# macro_rules! b(\n"
" ( ($e :expr) ~ ($p :pat) else $err :stmt ;\n"
" $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*\n"
" binds $( $bind_res:ident ),*\n"
" )\n"
"# => (0))\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:321
msgid ""
"The resulting macro looks like this. Note that the separation into "
"`biased_match!` and `biased_match_rec!` occurs only because we have an outer "
"piece of syntax (the `let`) which we only want to transcribe once."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:342
#, no-wrap
msgid ""
"macro_rules! biased_match_rec (\n"
" // Handle the first layer\n"
" ( ($e :expr) ~ ($p :pat) else $err :stmt ;\n"
" $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*\n"
" binds $( $bind_res:ident ),*\n"
" ) => (\n"
" match $e {\n"
" $p => {\n"
" // Recursively handle the next layer\n"
" biased_match_rec!($( ($e_rest) ~ ($p_rest) else $err_rest ; )*\n"
" binds $( $bind_res ),*\n"
" )\n"
" }\n"
" _ => { $err }\n"
" }\n"
" );\n"
" ( binds $( $bind_res:ident ),* ) => ( ($( $bind_res ),*) )\n"
")\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:364
#, no-wrap
msgid ""
"// Wrap the whole thing in a `let`.\n"
"macro_rules! biased_match (\n"
" // special case: `let (x) = ...` is illegal, so use `let x = ...` instead\n"
" ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*\n"
" binds $bind_res:ident\n"
" ) => (\n"
" let ( $( $bind_res ),* ) = biased_match_rec!(\n"
" $( ($e) ~ ($p) else $err ; )*\n"
" binds $bind_res\n"
" );\n"
" );\n"
" // more than one name: use a tuple\n"
" ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*\n"
" binds $( $bind_res:ident ),*\n"
" ) => (\n"
" let ( $( $bind_res ),* ) = biased_match_rec!(\n"
" $( ($e) ~ ($p) else $err ; )*\n"
" binds $( $bind_res ),*\n"
" );\n"
" )\n"
")\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:378
#, no-wrap
msgid ""
"# enum t1 { good_1(t2, uint), bad_1 };\n"
"# pub struct t2 { body: t3 }\n"
"# enum t3 { good_2(uint), bad_2};\n"
"# fn f(x: t1) -> uint {\n"
"biased_match!(\n"
" (x) ~ (good_1(g1, val)) else { return 0 };\n"
" (g1.body) ~ (good_2(result) ) else { fail!(\"Didn't get good_2\") };\n"
" binds val, result )\n"
"// complicated stuff goes here\n"
"return result + val;\n"
"# }\n"
"~~~~\n"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:382
msgid ""
"This technique applies to many cases where transcribing a result all at once "
"is not possible. The resulting code resembles ordinary functional "
"programming in some respects, but has some important differences from "
"functional programming."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:390
msgid ""
"The first difference is important, but also easy to forget: the "
"transcription (right-hand) side of a `macro_rules!` rule is literal syntax, "
"which can only be executed at run-time. If a piece of transcription syntax "
"does not itself appear inside another macro invocation, it will become part "
"of the final program. If it is inside a macro invocation (for example, the "
"recursive invocation of `biased_match_rec!`), it does have the opportunity "
"to affect transcription, but only through the process of attempted pattern "
"matching."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:398
msgid ""
"The second, related, difference is that the evaluation order of macros feels "
"\"backwards\" compared to ordinary programming. Given an invocation `m1!(m2!"
"())`, the expander first expands `m1!`, giving it as input the literal "
"syntax `m2!()`. If it transcribes its argument unchanged into an appropriate "
"position (in particular, not as an argument to yet another macro "
"invocation), the expander will then proceed to evaluate `m2!()` (along with "
"any other macro invocations `m1!(m2!())` produced)."
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:400
msgid "# A final note"
msgstr ""
#. type: Plain text
#: doc/tutorial-macros.md:407
msgid ""
"Macros, as currently implemented, are not for the faint of heart. Even "
"ordinary syntax errors can be more difficult to debug when they occur inside "
"a macro, and errors caused by parse problems in generated code can be very "
"tricky. Invoking the `log_syntax!` macro can help elucidate intermediate "
"states, invoking `trace_macros!(true)` will automatically print those "
"intermediate states out, and passing the flag `--pretty expanded` as a "
"command-line argument to the compiler will show the result of expansion."
msgstr ""

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff