|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>はじめに - </title> |
| 6 | + <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
| 7 | + <meta name="description" content=""> |
| 8 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 9 | + |
| 10 | + <base href=""> |
| 11 | + |
| 12 | + <link rel="stylesheet" href="book.css"> |
| 13 | + <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'> |
| 14 | + |
| 15 | + <link rel="shortcut icon" href="favicon.png"> |
| 16 | + |
| 17 | + <!-- Font Awesome --> |
| 18 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> |
| 19 | + |
| 20 | + <link rel="stylesheet" href="highlight.css"> |
| 21 | + <link rel="stylesheet" href="tomorrow-night.css"> |
| 22 | + |
| 23 | + <!-- MathJax --> |
| 24 | + <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| 25 | + |
| 26 | + <!-- Fetch JQuery from CDN but have a local fallback --> |
| 27 | + <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> |
| 28 | + <script> |
| 29 | + if (typeof jQuery == 'undefined') { |
| 30 | + document.write(unescape("%3Cscript src='jquery.js'%3E%3C/script%3E")); |
| 31 | + } |
| 32 | + </script> |
| 33 | + </head> |
| 34 | + <body class="light"> |
| 35 | + <!-- Set the theme before any content is loaded, prevents flash --> |
| 36 | + <script type="text/javascript"> |
| 37 | + var theme = localStorage.getItem('theme'); |
| 38 | + if (theme == null) { theme = 'light'; } |
| 39 | + $('body').removeClass().addClass(theme); |
| 40 | + </script> |
| 41 | + |
| 42 | + <!-- Hide / unhide sidebar before it is displayed --> |
| 43 | + <script type="text/javascript"> |
| 44 | + var sidebar = localStorage.getItem('sidebar'); |
| 45 | + if (sidebar === "hidden") { $("html").addClass("sidebar-hidden") } |
| 46 | + else if (sidebar === "visible") { $("html").addClass("sidebar-visible") } |
| 47 | + </script> |
| 48 | + |
| 49 | + <div id="sidebar" class="sidebar"> |
| 50 | + <ul class="chapter"><li class="affix"><a href="README.html" class="active">はじめに</a></li><li><a href="meet-safe-and-unsafe.html"><strong>1.</strong> 安全と危険のご紹介</a></li><li><ul class="section"><li><a href="safe-unsafe-meaning.html"><strong>1.1.</strong> 安全と危険の相互作用</a></li><li><a href="working-with-unsafe.html"><strong>1.2.</strong> Working with Unsafe</a></li></ul></li><li><a href="data.html"><strong>2.</strong> Data Layout</a></li><li><ul class="section"><li><a href="repr-rust.html"><strong>2.1.</strong> repr(Rust)</a></li><li><a href="exotic-sizes.html"><strong>2.2.</strong> Exotically Sized Types</a></li><li><a href="other-reprs.html"><strong>2.3.</strong> Other reprs</a></li></ul></li><li><a href="ownership.html"><strong>3.</strong> Ownership</a></li><li><ul class="section"><li><a href="references.html"><strong>3.1.</strong> References</a></li><li><a href="lifetimes.html"><strong>3.2.</strong> Lifetimes</a></li><li><a href="lifetime-mismatch.html"><strong>3.3.</strong> Limits of Lifetimes</a></li><li><a href="lifetime-elision.html"><strong>3.4.</strong> Lifetime Elision</a></li><li><a href="unbounded-lifetimes.html"><strong>3.5.</strong> Unbounded Lifetimes</a></li><li><a href="hrtb.html"><strong>3.6.</strong> Higher-Rank Trait Bounds</a></li><li><a href="subtyping.html"><strong>3.7.</strong> Subtyping and Variance</a></li><li><a href="dropck.html"><strong>3.8.</strong> Drop Check</a></li><li><a href="phantom-data.html"><strong>3.9.</strong> PhantomData</a></li><li><a href="borrow-splitting.html"><strong>3.10.</strong> Splitting Borrows</a></li></ul></li><li><a href="conversions.html"><strong>4.</strong> Type Conversions</a></li><li><ul class="section"><li><a href="coercions.html"><strong>4.1.</strong> Coercions</a></li><li><a href="dot-operator.html"><strong>4.2.</strong> The Dot Operator</a></li><li><a href="casts.html"><strong>4.3.</strong> Casts</a></li><li><a href="transmutes.html"><strong>4.4.</strong> Transmutes</a></li></ul></li><li><a href="uninitialized.html"><strong>5.</strong> Uninitialized Memory</a></li><li><ul class="section"><li><a href="checked-uninit.html"><strong>5.1.</strong> Checked</a></li><li><a href="drop-flags.html"><strong>5.2.</strong> Drop Flags</a></li><li><a href="unchecked-uninit.html"><strong>5.3.</strong> Unchecked</a></li></ul></li><li><a href="obrm.html"><strong>6.</strong> Ownership Based Resource Management</a></li><li><ul class="section"><li><a href="constructors.html"><strong>6.1.</strong> Constructors</a></li><li><a href="destructors.html"><strong>6.2.</strong> Destructors</a></li><li><a href="leaking.html"><strong>6.3.</strong> Leaking</a></li></ul></li><li><a href="unwinding.html"><strong>7.</strong> Unwinding</a></li><li><ul class="section"><li><a href="exception-safety.html"><strong>7.1.</strong> Exception Safety</a></li><li><a href="poisoning.html"><strong>7.2.</strong> Poisoning</a></li></ul></li><li><a href="concurrency.html"><strong>8.</strong> Concurrency</a></li><li><ul class="section"><li><a href="races.html"><strong>8.1.</strong> Races</a></li><li><a href="send-and-sync.html"><strong>8.2.</strong> Send and Sync</a></li><li><a href="atomics.html"><strong>8.3.</strong> Atomics</a></li></ul></li><li><a href="vec.html"><strong>9.</strong> Implementing Vec</a></li><li><ul class="section"><li><a href="vec-layout.html"><strong>9.1.</strong> Layout</a></li><li><a href="vec-alloc.html"><strong>9.2.</strong> Allocating</a></li><li><a href="vec-push-pop.html"><strong>9.3.</strong> Push and Pop</a></li><li><a href="vec-dealloc.html"><strong>9.4.</strong> Deallocating</a></li><li><a href="vec-deref.html"><strong>9.5.</strong> Deref</a></li><li><a href="vec-insert-remove.html"><strong>9.6.</strong> Insert and Remove</a></li><li><a href="vec-into-iter.html"><strong>9.7.</strong> IntoIter</a></li><li><a href="vec-raw.html"><strong>9.8.</strong> RawVec</a></li><li><a href="vec-drain.html"><strong>9.9.</strong> Drain</a></li><li><a href="vec-zsts.html"><strong>9.10.</strong> Handling Zero-Sized Types</a></li><li><a href="vec-final.html"><strong>9.11.</strong> Final Code</a></li></ul></li><li><a href="arc-and-mutex.html"><strong>10.</strong> Implementing Arc and Mutex</a></li></ul> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div id="page-wrapper" class="page-wrapper"> |
| 54 | + |
| 55 | + <div class="page"> |
| 56 | + <div id="menu-bar" class="menu-bar"> |
| 57 | + <div class="left-buttons"> |
| 58 | + <i id="sidebar-toggle" class="fa fa-bars"></i> |
| 59 | + <i id="theme-toggle" class="fa fa-paint-brush"></i> |
| 60 | + </div> |
| 61 | + |
| 62 | + <h1 class="menu-title"></h1> |
| 63 | + |
| 64 | + <div class="right-buttons"> |
| 65 | + <i id="print-button" class="fa fa-print" title="Print this book"></i> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + |
| 69 | + <div id="content" class="content"> |
| 70 | + <!-- The Rustonomicon --> |
| 71 | +<a class="header" href="#rust-の裏側" name="rust-の裏側"><h1>Rust の裏側</h1></a> |
| 72 | +<!-- The Dark Arts of Advanced and Unsafe Rust Programming --> |
| 73 | +<a class="header" href="#高度で危険な-rust-programming-のための闇の技法" name="高度で危険な-rust-programming-のための闇の技法"><h4>高度で危険な Rust Programming のための闇の技法</h4></a> |
| 74 | +<!-- NOTE: This is a draft document, and may contain serious errors --> |
| 75 | +<a class="header" href="#note-この文書はドラフトです重大な間違いを含んでいるかもしれません" name="note-この文書はドラフトです重大な間違いを含んでいるかもしれません"><h1>NOTE: この文書はドラフトです。重大な間違いを含んでいるかもしれません。</h1></a> |
| 76 | +<!-- |
| 77 | +Instead of the programs I had hoped for, there came only a shuddering blackness and ineffable loneliness; and I saw at last a fearful truth which no one had ever dared to breathe before — the unwhisperable secret of secrets — The fact that this language of stone and stridor is not a sentient perpetuation of Rust as London is of Old London and Paris of Old Paris, but that it is in fact quite unsafe, its sprawling body imperfectly embalmed and infested with queer animate things which have nothing to do with it as it was in compilation. |
| 78 | +--> |
| 79 | +<blockquote> |
| 80 | +<p>私に与えられたのは、望んだようなプログラムではなく、身を震わせるような暗黒と言い表せないような孤独であった。そして私はついに、誰ひとり口にしようともしなかった恐ろしい真実、ささやくことすらできない神秘中の神秘を目にしたのだ。石のように硬く、耳障りな音をたてるこの言語は、ロンドンが古きロンドンではなく、パリが古きパリではないように、Rust の御代をとこしえにするものではなく、実はきわめて危険で、不完全に防腐処理された、だらしなく寝そべった死体だったのだ。そこにはコンパイル時に生まれた奇妙な生き物たちが所在なさげに蔓延っていた。</p> |
| 81 | +<p>(訳注: H.P. ラヴクラフトの小説「<a href="http://quotes.yourdictionary.com/author/h-p-lovecraft/172934">あの人</a>」のパロディのようです。)</p> |
| 82 | +</blockquote> |
| 83 | +<!-- |
| 84 | +This book digs into all the awful details that are necessary to understand in order to write correct Unsafe Rust programs. Due to the nature of this problem, it may lead to unleashing untold horrors that shatter your psyche into a billion infinitesimal fragments of despair. |
| 85 | +--> |
| 86 | +<p>この本は、危険な Rust プログラムを正しく書くために理解しなくてはいけない、不愉快な詳細について詳しく見ていきます。このような性質上、この文書は今まで語られることのなかった恐怖を解き放ち、あなたの精神を何十億もの絶望のかけらに砕いてしまうかもしれません。</p> |
| 87 | +<!-- |
| 88 | +Should you wish a long and happy career of writing Rust programs, you should turn back now and forget you ever saw this book. It is not necessary. However if you intend to write unsafe code -- or just want to dig into the guts of the language -- this book contains invaluable information. |
| 89 | +--> |
| 90 | +<p>もし貴方が Rust とともに長く幸せな人生を歩みたいと望むなら、今すぐに背を向けて、この本を見てしまったことを忘れるのです。貴方には必要ないのですから。しかし、危険なコードを書く意思がもしも貴方にあるのなら、もしくはこの言語の最重要部にただ踏み込んでみたいのなら、この本は代えがたい情報をもたらすでしょう。</p> |
| 91 | +<!-- |
| 92 | +Unlike [The Book][trpl] we will be assuming considerable prior knowledge. In |
| 93 | +particular, you should be comfortable with basic systems programming and Rust. |
| 94 | +If you don't feel comfortable with these topics, you should consider [reading |
| 95 | +The Book][trpl] first. Though we will not be assuming that you have, and will |
| 96 | +take care to occasionally give a refresher on the basics where appropriate. You |
| 97 | +can skip straight to this book if you want; just know that we won't be |
| 98 | +explaining everything from the ground up. |
| 99 | +--> |
| 100 | +<p><a href="../book/index.html">The Book</a> とは異なり、ここでは多くの事前知識を前提としています。特に基本的なシステムプログラミングと Rust に精通していなくてはなりません。もし貴方がそうでないなら、まず <a href="../book/index.html">The Book を読む</a> べきでしょう。とはいえ、The Book は前提ではありませんし、適切な場面で基本知識を復習する機会を与えます。The Book を飛ばしてこの本を読んでも構いませんが、すべてが基礎から説明されるわけではないことを覚えておいてください。</p> |
| 101 | +<!-- |
| 102 | +To be clear, this book goes into deep detail. We're going to dig into |
| 103 | +exception-safety, pointer aliasing, memory models, and even some type-theory. |
| 104 | +We will also be spending a lot of time talking about the different kinds |
| 105 | +of safety and guarantees. |
| 106 | +--> |
| 107 | +<p>はっきり言いますが、この本は詳細について深く説明します。例外の安全性、ポインタエイリアシング、メモリモデル、そして型理論についても少し。また、様々な種類の安全性や保証についてもたくさん説明します。</p> |
| 108 | + |
| 109 | + </div> |
| 110 | + |
| 111 | + <!-- Mobile navigation buttons --> |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + <a href="meet-safe-and-unsafe.html" class="mobile-nav-chapters next"> |
| 116 | + <i class="fa fa-angle-right"></i> |
| 117 | + </a> |
| 118 | + |
| 119 | + |
| 120 | + </div> |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + <a href="meet-safe-and-unsafe.html" class="nav-chapters next" title="You can navigate through the chapters using the arrow keys"> |
| 126 | + <i class="fa fa-angle-right"></i> |
| 127 | + </a> |
| 128 | + |
| 129 | + |
| 130 | + </div> |
| 131 | + |
| 132 | + |
| 133 | + <!-- Local fallback for Font Awesome --> |
| 134 | + <script> |
| 135 | + if ($(".fa").css("font-family") !== "FontAwesome") { |
| 136 | + $('<link rel="stylesheet" type="text/css" href="_FontAwesome/css/font-awesome.css">').prependTo('head'); |
| 137 | + } |
| 138 | + </script> |
| 139 | + |
| 140 | + <!-- Livereload script (if served using the cli tool) --> |
| 141 | + |
| 142 | + |
| 143 | + <script src="highlight.js"></script> |
| 144 | + <script src="book.js"></script> |
| 145 | + </body> |
| 146 | +</html> |
0 commit comments