Skip to content

Commit 65ec2a3

Browse files
committed
Merge pull request #65 from pocket7878/using-rust-without-the-standard-library
Using Rust Without The Standard Library
2 parents a18f069 + 105dd4d commit 65ec2a3

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

1.6/ja/book/using-rust-without-the-standard-library.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
% Using Rust Without the Standard Library
2-
3-
Rust’s standard library provides a lot of useful functionality, but assumes
4-
support for various features of its host system: threads, networking, heap
5-
allocation, and others. There are systems that do not have these features,
6-
however, and Rust can work with those too! To do so, we tell Rust that we
7-
don’t want to use the standard library via an attribute: `#![no_std]`.
8-
9-
> Note: This feature is technically stable, but there are some caveats. For
10-
> one, you can build a `#![no_std]` _library_ on stable, but not a _binary_.
11-
> For details on binaries without the standard library, see [the nightly
12-
> chapter on `#![no_std]`](no-stdlib.html)
13-
14-
To use `#![no_std]`, add a it to your crate root:
1+
% 標準ライブラリ無しでRustを使う
2+
<!-- % Using Rust Without the Standard Library -->
3+
4+
<!-- Rust’s standard library provides a lot of useful functionality, but assumes -->
5+
<!-- support for various features of its host system: threads, networking, heap -->
6+
<!-- allocation, and others. There are systems that do not have these features, -->
7+
<!-- however, and Rust can work with those too! To do so, we tell Rust that we -->
8+
<!-- don’t want to use the standard library via an attribute: `#![no_std]`. -->
9+
Rustの標準ライブラリは多くの便利な機能を提供している一方で、
10+
スレッド、ネットワーク、ヒープアロケーション、その他の多くの機能をホストシステムが提供していることを前提としています。
11+
一方で、それらの機能を提供していないシステムも存在します。しかし、Rustはそれらの上でも利用することができます!
12+
それは、Rustに標準ライブラリを利用しないということを `#![no_std]` アトリビュートを利用して伝えることで可能となります。
13+
14+
15+
<!-- > Note: This feature is technically stable, but there are some caveats. For -->
16+
<!-- > one, you can build a `#![no_std]` _library_ on stable, but not a _binary_. -->
17+
<!-- > For details on binaries without the standard library, see [the nightly -->
18+
<!-- > chapter on `#![no_std]`](no-stdlib.html) -->
19+
> メモ: このフィーチャーは技術的には安定していますが、いくつか注意点が有ります。
20+
> 例えば、 `#![no_std]` を含んだ _ライブラリ_ は 安定版でビルド可能ですが、 _バイナリ_ はビルド不可能です。
21+
> 標準ライブラリを利用しないバイナリについては [`#![no_std]` についての不安定版のドキュメント](no-stdlib.html) を確認してください。
22+
23+
<!-- To use `#![no_std]`, add a it to your crate root: -->
24+
`#![no_std]` アトリビュートを利用するには、クレートのトップに以下のように追加します:
1525

1626
```rust
1727
#![no_std]
@@ -21,12 +31,19 @@ fn plus_one(x: i32) -> i32 {
2131
}
2232
```
2333

24-
Much of the functionality that’s exposed in the standard library is also
25-
available via the [`core` crate](../core/). When we’re using the standard
26-
library, Rust automatically brings `std` into scope, allowing you to use
27-
its features without an explicit import. By the same token, when using
28-
`!#[no_std]`, Rust will bring `core` into scope for you, as well as [its
29-
prelude](../core/prelude/v1/). This means that a lot of code will Just Work:
34+
<!-- Much of the functionality that’s exposed in the standard library is also -->
35+
<!-- available via the [`core` crate](../core/). When we’re using the standard -->
36+
<!-- library, Rust automatically brings `std` into scope, allowing you to use -->
37+
<!-- its features without an explicit import. By the same token, when using -->
38+
<!-- `!#[no_std]`, Rust will bring `core` into scope for you, as well as [its -->
39+
<!-- prelude](../core/prelude/v1/). This means that a lot of code will Just Work: -->
40+
標準ライブラリで提供されている多くの機能は [`core` クレート](../core/) を用いることでも利用できます。
41+
標準ライブラリを利用しているとき、Rustは自動的に `std` をスコープに導入し、
42+
標準ライブラリの機能を明示的にインポートすること無しに利用可能にします。
43+
それと同じように、もし `#![no_std]` を利用しているときは、
44+
Rustは自動的に `core`[そのプレリュード](../core/prelude/v1/) をスコープに導入します。
45+
これは、例えば多くの以下のようなコードが動作することを意味しています:
46+
3047

3148
```rust
3249
#![no_std]

0 commit comments

Comments
 (0)