Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust ownership from legal perspective
Search
homuler
May 30, 2016
Programming
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust ownership from legal perspective
Rustのownershipは所有権ではなかった件
homuler
May 30, 2016
More Decks by homuler
See All by homuler
JavaScript Course at Arzano Royal Institute of Magic
homuler
0
89
Style Transfer Overview in 5 minutes
homuler
0
100
Other Decks in Programming
See All in Programming
スマート反転とウェブアクセシビリティ
camiha
0
160
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
210
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
180
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
4
1.7k
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
120
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
440
Webプラットフォームで議論されているセキュリティ課題 / Security issues being discussed on Web Platforms
petamoriken
0
260
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
Deep dive into the select statement (GopherCon UK)
jespino
0
170
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
420
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
680
Featured
See All Featured
Fireside Chat
paigeccino
42
4k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
520
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
A Tale of Four Properties
chriscoyier
163
24k
Navigating Weather and Climate Data
rabernat
0
510
Prompt Engineering for Job Search
mfonobong
0
450
Ruling the World: When Life Gets Gamed
codingconduct
0
330
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
A designer walks into a library…
pauljervisheath
211
25k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Transcript
Rustのownershipは 所有権のこと だと思った?
1. Rust • Mozillaが開発中のプログラミング言語 – C++が対抗馬 • GCがないが、メモリ安全性を担保 • Firefox(Gecko)の一部実装に使われている
– https://wiki.mozilla.org/Oxidation
2. Memory safe • Ownership – 所有権にたとえられる • Borrowing –
(使用/消費)貸借にたとえられる • Lifetimes
2. Memory safe • Ownership – 所有権? • Borrowing –
(使用/消費)貸借? • Lifetimes – 「人が深淵を覗く時、深淵もまた人を覗いている」
3. OwnershipとBorrowing • 変数宣言に関するルール • ある値に対するownershipを持つ変数(x)がある • 別の変数が同じ値を使う際は、(xの)ownershipをborrowする – この表現がかなりミソ
• 常にどちらかの状態を維持する – 値を参照するだけの変数(Immutable borrowing)が複数 – 値を変更可能な変数(Mutable borrowing)がただ一つ • 違反するとコンパイルエラー • 実行時のオーバーヘッドはない – コンパイル時チェックのみ
本当に貸借? borrowingのサンプル // コンパイルエラーになる fn main() { let xs =
vec![1, 2, 3]; for x in xs { println!("{}", x); } println!("{:?}", xs); }
本当に貸借? borrowingのサンプル // コンパイルエラーになる fn main() { let xs =
vec![1, 2, 3]; for x in xs { // move(ownershipが移る) println!("{}", x); } println!("{:?}", xs); // Error }
本当に貸借? borrowingのサンプル fn main() { let xs = vec![1, 2,
3]; for x in &xs { // borrowing(ownershipはそのまま) println!("{}", x); } println!("{:?}", xs); }
本当に貸借? borrowingのサンプル fn main() { let xs = vec![1, 2,
3]; for x in &xs { // borrowing(ownershipはそのまま) println!("{}", x); } println!("{:?}", xs); } 見せてもらっただけ、だけど一応借りてそう
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &Vec<usize>) { while
xs.len() > 0 { xs.pop(); // Error(Immutable!) } } fn main() { let xs = vec![1, 2, 3]; emptify(&xs); }
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &mut Vec<usize>) { while
xs.len() > 0 { xs.pop(); } } fn main() { let mut xs = vec![1, 2, 3]; emptify(&mut xs); }
本当に所有権? Borrowingのサンプル(mutable) // 配列を空にする fn emptify(xs: &mut Vec<usize>) {
while xs.len() > 0 { xs.pop(); } } fn main() { let mut xs = vec![1, 2, 3]; emptify(&mut xs); } 中身全部抜いてますけど・・
5. Borrowing再考 • Immutableのborrowing – 値は見るだけ – 法律行為(契約)でない可能性も • 渋谷駅にある「明日の神話」みたいな
• 警備員(コンパイラ)に止められるだけ • 入場規制はあるので、微妙なところ – 揚げ足を取るのはやめます
5. Borrowing再考 • Mutableのborrowing – 「借主」はやりたい放題 – もはや所有権を一度譲渡しているように見える – いずれ返されるので、「貸主」は何か
(ownership)を保持しているはず
• そういえば、ローマ法にあった – 「権原」 – 所有権の上位概念で、所有権の根拠になるもの – 日本では立法者が理解できなかったので、権原≒所有権 • 所有権だって条件(期限)付き譲渡できる、はず
– (日本法だと苦しい) – cf. 忘恩行為による贈与取り消し、終期付き譲渡など (東京地裁昭和50年12月25日判決) – 日本法ではなかった • 所有権(ownership)を借りる(borrow)という表現自体がおかしい • 「何か」 = ownership ≒ 権原 ≠ 所有権 Q.E.D 6. Ownership再考
まとめ • 譬え話にマジレスしてはいけない • でも、Rustはいいものです