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
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
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust超初心者が頑張って勉強するの巻き
Search
ieiriyuki
January 16, 2019
430
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust超初心者が頑張って勉強するの巻き
ieiriyuki
January 16, 2019
More Decks by ieiriyuki
See All by ieiriyuki
データドリブンな幸せになる方法
ieiriyuki
0
91
dynamic_pricing_fundamentals
ieiriyuki
1
1.5k
ラズパイとスラックで作るミーティングスペースモニタリングツール
ieiriyuki
2
760
スキルアップ・キャッチアップこうやってます
ieiriyuki
1
650
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
490
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
520
HDC tutorial
michielstock
2
940
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The World Runs on Bad Software
bkeepers
PRO
72
12k
A Soul's Torment
seathinner
8
3.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
BBQ
matthewcrist
89
10k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Transcript
Rust超初心者が 頑張って勉強するの巻き Shinjuku.rs #2 2019-01-16
自己紹介 ieiriyuki データサイエンティスト もっぱらPythonで機械学習モデルを書く 大学時代は進化シミュレーションのためにC/C++を少しやっていた 「C/C++に死を」という記事でRustを知る (C++は死ぬ必要ないです)
t_wadaさんのスライド 12月ごろあたりから少し時間ができたので、Rustをちゃんと勉強しようと思い立つ 毎日ちょっとずつでもコードを書く GitHubに上げる (https://github.com/ieiriyuki/rust-hello) 写経なので意味があるかは... https://speakerdeck.com/rtechkouhou/enziniatositekofalsexian-sheng-kifalsekorutameni?slide=49
やっていること ひたすらにRust by Example を写経する 今std miscの部分 1月中には終わる?
割と順調にいっています 週末にまとめてやるよりも、モチベ的にも 記憶的にもやりやすい もうちょっと一日当たりの量を増やしたい (今は20~40分くらい)
Borrow fn eat_box_i32(boxed_i32: Box<i32>) { println!("Destroying box that contains {}",
boxed_i32); } fn borrow_i32(borrowed_i32: &i32) { println!("This int is: {}", borrowed_i32); } fn main() { let boxed_i32 = Box::new(5_i32); let stacked_i32 = 6_i32; borrow_i32(&boxed_i32); borrow_i32(&stacked_i32); { let _ref_to_i32: &i32 = &boxed_i32; eat_box_i32(boxed_i32); // Error ! } eat_box_i32(boxed_i32); } ここで借用しているためデータを破 棄するような操作はできない
Bound <>で囲まれているところが、バウンドを指定している とはいえ、バウンドの価値はよくわかっていない... ジェネリクスがあるのは便利だってGo勉強している人が言ってた #[derive(Debug)] struct Ref<'a, T: 'a>(&'a T);
// `Ref` contains a reference to a generic type `T` that has // an unknown lifetime `'a`. `T` is bounded such that any // *references* in `T` must outlive `'a`. Additionally, the lifetime // of `Ref` may not exceed `'a`.
Traits Sheepというstructに対し て、Animalというトレイトを 実装しています よく使うメソッドの集合っ てことでしょうか? struct Sheep { naked:
bool, name: &'static str } trait Animal { fn new(name: &'static str) -> Self; fn name(&self) -> &'static str; fn noise(&self) -> &'static str; fn talk(&self) { println!("{} says {}", self.name(), self.noise()); } } // ~~ skip ~~ // impl Animal for Sheep { fn new(name: &'static str) -> Sheep { Sheep { name: name, naked: false } } fn name(&self) -> &'static str { self.name } fn noise(&self) -> &'static str { if self.is_naked() { "baaaaah?" } else { "baaaaah!" } } fn talk(&self) { println!("{} pauses briefly... {}", self.name, self.noise()); } }
そのうち本のほうも手を出す 手元にはある 来年から本気出す
今後やりたいこと JavaやC++で機械学習実装できるんなら、Rustでもできるはず 価値があるかは知らない...笑 とりあえずやってみたい 競プロでもRust使えるらしい (AtCoderはバージョンが古いらしい...) 別のRust LTでみたWeb Assemblyは面白そうだった これからも頑張りたいと思います!
ありがとうございました!