Skip to content

Instantly share code, notes, and snippets.

@uta8a
Created July 2, 2019 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uta8a/85221c89d6df3abb47e622f8f3dcfd85 to your computer and use it in GitHub Desktop.
Save uta8a/85221c89d6df3abb47e622f8f3dcfd85 to your computer and use it in GitHub Desktop.

20190702今日の精進

蟻本再び読み始めた

Rustのmod, trait, implが分からない

抽象的なので書いてから文献読んでまた書き直したい

  • mod: namespaceのようなもの?名前空間っぽい
  • trait: selfの中身になるもの?これは型
  • impl: traitに対し関数が定義されているとき、そのtraitをVecなど他の型に広げる。
  • fn: implの中で使う。型に対して関数を定義

使う時は

vig::S::binary_search  

のようになる。

疑問とか改善したいこと

  • 名前衝突回避のためにmod vigしているがもっといい方法はあるだろうか?
  • as xxxが多すぎるけどこれを減らせないだろうか?
  • もっと抽象的な実装にできないだろうか?(u64に対するものになってしまっている)

  • とりあえず、くじびきHardを実装する。ページ進める。
  • メモ: Rustで二分探索を使う問題を解く
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment