Skip to content

5.12. Using Rust without the Standard Library (1.9) #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions 1.9/ja/book/using-rust-without-the-standard-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
<!-- allocation, and others. There are systems that do not have these features, -->
<!-- however, and Rust can work with those too! To do so, we tell Rust that we -->
<!-- don’t want to use the standard library via an attribute: `#![no_std]`. -->
Rustの標準ライブラリは多くの便利な機能を提供している一方で、
スレッド、ネットワーク、ヒープアロケーション、その他の多くの機能をホストシステムが提供していることを前提としています
一方で、それらの機能を提供していないシステムも存在します。しかし、Rustはそれらの上でも利用することができます!
Rustの標準ライブラリは多くの便利な機能を提供している一方で、スレッド、ネットワーク、ヒープアロケーション、その他の多くの機能をホストシステムが提供していることを前提としています。
一方で、それらの機能を提供していないシステムも存在します
しかし、Rustはそれらの上でも利用できます!
それは、Rustに標準ライブラリを利用しないということを `#![no_std]` アトリビュートを利用して伝えることで可能となります。


<!-- > Note: This feature is technically stable, but there are some caveats. For -->
<!-- > one, you can build a `#![no_std]` _library_ on stable, but not a _binary_. -->
<!-- > For details on binaries without the standard library, see [the nightly -->
<!-- > chapter on `#![no_std]`](no-stdlib.html) -->
> メモ: このフィーチャーは技術的には安定していますが、いくつか注意点が有ります
> メモ: このフィーチャーは技術的には安定していますが、いくつか注意点があります
> 例えば、 `#![no_std]` を含んだ _ライブラリ_ は 安定版でビルド可能ですが、 _バイナリ_ はビルド不可能です。
> 標準ライブラリを利用しないバイナリについては [`#![no_std]` についての不安定版のドキュメント](no-stdlib.html) を確認してください。

<!-- To use `#![no_std]`, add a it to your crate root: -->
<!-- To use `#![no_std]`, add it to your crate root: -->
`#![no_std]` アトリビュートを利用するには、クレートのトップに以下のように追加します:

```rust
Expand All @@ -35,16 +34,13 @@ fn plus_one(x: i32) -> i32 {
<!-- available via the [`core` crate](../core/). When we’re using the standard -->
<!-- library, Rust automatically brings `std` into scope, allowing you to use -->
<!-- its features without an explicit import. By the same token, when using -->
<!-- `!#[no_std]`, Rust will bring `core` into scope for you, as well as [its -->
<!-- `#![no_std]`, Rust will bring `core` into scope for you, as well as [its -->
<!-- prelude](../core/prelude/v1/). This means that a lot of code will Just Work: -->
標準ライブラリで提供されている多くの機能は [`core` クレート](../core/) を用いることでも利用できます。
標準ライブラリを利用しているとき、Rustは自動的に `std` をスコープに導入し、
標準ライブラリの機能を明示的にインポートすること無しに利用可能にします。
それと同じように、もし `#![no_std]` を利用しているときは、
Rustは自動的に `core` と [そのプレリュード](../core/prelude/v1/) をスコープに導入します。
標準ライブラリを利用しているとき、Rustは自動的に `std` をスコープに導入し、標準ライブラリの機能を明示的にインポートすること無しに利用可能にします。
それと同じように、もし `#![no_std]` を利用しているときは、Rustは自動的に `core` と [そのプレリュード](../core/prelude/v1/) をスコープに導入します。
これは、例えば多くの以下のようなコードが動作することを意味しています:


```rust
#![no_std]

Expand Down

This file was deleted.