4
4
< meta charset ="utf-8 ">
5
5
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
6
< meta name ="generator " content ="rustdoc ">
7
- < title > Using Rust Without the Standard Library </ title >
7
+ < title > 標準ライブラリ無しでRustを使う </ title >
8
8
9
9
< link rel ="stylesheet " type ="text/css " href ="rustbook.css ">
10
10
185
185
< div id ='page '>
186
186
187
187
188
- < h1 class ="title "> Using Rust Without the Standard Library</ h1 >
189
- < p > Rust’s standard library provides a lot of useful functionality, but assumes
190
- support for various features of its host system: threads, networking, heap
191
- allocation, and others. There are systems that do not have these features,
192
- however, and Rust can work with those too! To do so, we tell Rust that we
193
- don’t want to use the standard library via an attribute: < code > #![no_std]</ code > .</ p >
188
+ < h1 class ="title "> 標準ライブラリ無しでRustを使う</ h1 >
189
+ <!-- % Using Rust Without the Standard Library -->
190
+
191
+ <!-- Rust’s standard library provides a lot of useful functionality, but assumes -->
192
+
193
+ <!-- support for various features of its host system: threads, networking, heap -->
194
+
195
+ <!-- allocation, and others. There are systems that do not have these features, -->
196
+
197
+ <!-- however, and Rust can work with those too! To do so, we tell Rust that we -->
198
+
199
+ <!-- don’t want to use the standard library via an attribute: `#![no_std]`. -->
200
+
201
+ < p > Rustの標準ライブラリは多くの便利な機能を提供している一方で、
202
+ スレッド、ネットワーク、ヒープアロケーション、その他の多くの機能をホストシステムが提供していることを前提としています。
203
+ 一方で、それらの機能を提供していないシステムも存在します。しかし、Rustはそれらの上でも利用することができます!
204
+ それは、Rustに標準ライブラリを利用しないということを < code > #![no_std]</ code > アトリビュートを利用して伝えることで可能となります。</ p >
205
+
206
+ <!-- > Note: This feature is technically stable, but there are some caveats. For -->
207
+
208
+ <!-- > one, you can build a `#![no_std]` _library_ on stable, but not a _binary_. -->
209
+
210
+ <!-- > For details on binaries without the standard library, see [the nightly -->
211
+
212
+ <!-- > chapter on `#![no_std]`](no-stdlib.html) -->
194
213
195
214
< blockquote >
196
- < p > Note: This feature is technically stable, but there are some caveats. For
197
- one, you can build a < code > #![no_std]</ code > < em > library</ em > on stable, but not a < em > binary</ em > .
198
- For details on binaries without the standard library, see < a href ="no-stdlib.html "> the nightly
199
- chapter on < code > #![no_std]</ code > </ a > </ p >
215
+ < p > メモ: このフィーチャーは技術的には安定していますが、いくつか注意点が有ります。
216
+ 例えば、 < code > #![no_std]</ code > を含んだ < em > ライブラリ</ em > は 安定版でビルド可能ですが、 < em > バイナリ</ em > はビルド不可能です。
217
+ 標準ライブラリを利用しないバイナリについては < a href ="no-stdlib.html "> < code > #![no_std]</ code > についての不安定版のドキュメント</ a > を確認してください。</ p >
200
218
</ blockquote >
201
219
202
- < p > To use < code > #![no_std]</ code > , add a it to your crate root:</ p >
220
+ <!-- To use `#![no_std]`, add a it to your crate root: -->
221
+
222
+ < p > < code > #![no_std]</ code > アトリビュートを利用するには、クレートのトップに以下のように追加します:</ p >
203
223
< span class ='rusttest '> fn main() {
204
224
#![no_std]
205
225
@@ -213,12 +233,24 @@ <h1 class="title">Using Rust Without the Standard Library</h1>
213
233
< span class ='ident '> x</ span > < span class ='op '> +</ span > < span class ='number '> 1</ span >
214
234
}</ pre >
215
235
216
- < p > Much of the functionality that’s exposed in the standard library is also
217
- available via the < a href ="../core/ "> < code > core</ code > crate</ a > . When we’re using the standard
218
- library, Rust automatically brings < code > std</ code > into scope, allowing you to use
219
- its features without an explicit import. By the same token, when using
220
- < code > !#[no_std]</ code > , Rust will bring < code > core</ code > into scope for you, as well as < a href ="../core/prelude/v1/ "> its
221
- prelude</ a > . This means that a lot of code will Just Work:</ p >
236
+ <!-- Much of the functionality that’s exposed in the standard library is also -->
237
+
238
+ <!-- available via the [`core` crate](../core/). When we’re using the standard -->
239
+
240
+ <!-- library, Rust automatically brings `std` into scope, allowing you to use -->
241
+
242
+ <!-- its features without an explicit import. By the same token, when using -->
243
+
244
+ <!-- `!#[no_std]`, Rust will bring `core` into scope for you, as well as [its -->
245
+
246
+ <!-- prelude](../core/prelude/v1/). This means that a lot of code will Just Work: -->
247
+
248
+ < p > 標準ライブラリで提供されている多くの機能は < a href ="../core/ "> < code > core</ code > クレート</ a > を用いることでも利用できます。
249
+ 標準ライブラリを利用しているとき、Rustは自動的に < code > std</ code > をスコープに導入し、
250
+ 標準ライブラリの機能を明示的にインポートすること無しに利用可能にします。
251
+ それと同じように、もし < code > #![no_std]</ code > を利用しているときは、
252
+ Rustは自動的に < code > core</ code > と < a href ="../core/prelude/v1/ "> そのプレリュード</ a > をスコープに導入します。
253
+ これは、例えば多くの以下のようなコードが動作することを意味しています:</ p >
222
254
< span class ='rusttest '> fn main() {
223
255
#![no_std]
224
256
0 commit comments