Skip to content

Commit 922be9c

Browse files
committed
translate obrm
1 parent beb095b commit 922be9c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* [Checked](checked-uninit.md)
3030
* [Drop Flags](drop-flags.md)
3131
* [Unchecked](unchecked-uninit.md)
32-
* [Ownership Based Resource Management](obrm.md)
32+
* [所有権に基づいたリソース管理](obrm.md)
3333
* [Constructors](constructors.md)
3434
* [Destructors](destructors.md)
3535
* [Leaking](leaking.md)

src/obrm.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# The Perils Of Ownership Based Resource Management (OBRM)
1+
<!-- # The Perils Of Ownership Based Resource Management (OBRM) -->
2+
# 所有権に基づいたリソース管理(Ownership Based Resource Management, OBRM)の危険性について
23

4+
<!--
35
OBRM (AKA RAII: Resource Acquisition Is Initialization) is something you'll
46
interact with a lot in Rust. Especially if you use the standard library.
7+
-->
8+
OBRM(またの名をRAII: Resource Acquisition Is Initialization)とは、Rustにおいて
9+
関連性の深い概念です。特に標準ライブラリと密接に関与します。
510

11+
<!--
612
Roughly speaking the pattern is as follows: to acquire a resource, you create an
713
object that manages it. To release the resource, you simply destroy the object,
814
and it cleans up the resource for you. The most common "resource" this pattern
@@ -12,3 +18,14 @@ particularly important in Rust because we have no pervasive GC to rely on for
1218
memory management. Which is the point, really: Rust is about control. However we
1319
are not limited to just memory. Pretty much every other system resource like a
1420
thread, file, or socket is exposed through this kind of API.
21+
-->
22+
このパターンを簡単に説明すると以下のようになります。リソースの獲得時に
23+
操作の対象となるオブジェクトの初期化を行い、リソースの解放時には単にその
24+
オブジェクトを破棄すればあとはリソースのクリーンアップを勝手に行ってくれる、
25+
いうものです。ここでいう「リソース」とは単に**メモリ**のことです。`Box``Rc`
26+
その他`std::collections`の諸々全ては、メモリの管理を便利にするためのものです。
27+
Rustの場合、メモリの管理において一貫したGCに頼るということができないので、これら
28+
は特に重要になります。大事なことなので強調しましょう。この「管理」という考え方は
29+
Rustの根幹です。それは何もメモリに限った話ではありません。スレッド、ファイル、
30+
ソケットといったほぼ全てのリソースがこういった考え方に基づくAPIを通して扱うように
31+
できています。

0 commit comments

Comments
 (0)