Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rustで書いたツールのdebianパッケージングに挑戦してみた話(仮)

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 Rustで書いたツールのdebianパッケージングに挑戦してみた話(仮)

最近個人的に触りだしたRustというプログラミング言語について、
そもそもどういう言語なんだというご紹介(といっても、私も勉強中の身ですが)と、
Rustで書いたツールのdebを作ってみる、というところまでを目標としています。

Avatar for Katsuki Kobayashi

Katsuki Kobayashi

March 24, 2019
Tweet

More Decks by Katsuki Kobayashi

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ ▶ Katsuki Kobayashi • ૊ΈࠐΈΤϯδχΞ • ࢖༻ݴޠ: C, Ξηϯϒϥ

    (ARM) • Ӭԕʹษڧத: Python, Kotlin, Ξηϯϒϥ (RISC-V), Rust ▶ Debian ͱͷ͖͍ͭ͋ • େֶ࣌୅ʹૉఢͳઌഐ͕ͨ (͏ͪݱࡏ DD2 ໊,DM1 ໊) ʹΑͬͯ෍ڭ • ݸਓతʹ͸ύοέʔδͷߏ੒ͷ౷Ұײ͕Ұ൪޷͖ ▶ Rust • ৽͍͠ݴޠ͕ษڧ͍ͨ͠ • Ͱ΋ Python ΍ Ruby ͸ωΠςΟϒͳόΠφϦʹͳΒͳͯ͘πϥ͍ • ͡Ό͋ Mozilla ޷͖ͩ͠ Rust ʹ͠Α͏
  2. ࣗݾ঺հ ▶ Katsuki Kobayashi • ૊ΈࠐΈΤϯδχΞ • ࢖༻ݴޠ: C, Ξηϯϒϥ

    (ARM) • Ӭԕʹษڧத: Python, Kotlin, Ξηϯϒϥ (RISC-V), Rust • ࠷ۙձࣾͰ C++Λษڧͤ͞ΒΕ͍ͯΔɻλεέςɻ ▶ Debian ͱͷ͖͍ͭ͋ • େֶ࣌୅ʹૉఢͳઌഐ͕ͨ (͏ͪݱࡏ DD2 ໊,DM1 ໊) ʹΑͬͯ෍ڭ • ݸਓతʹ͸ύοέʔδͷߏ੒ͷ౷Ұײ͕Ұ൪޷͖ • ͋Μ·Γߩݙ͍ͯ͠ͳ͍ ▶ Rust • ৽͍͠ݴޠ͕ษڧ͍ͨ͠ • Ͱ΋ Python ΍ Ruby ͸ωΠςΟϒͳόΠφϦʹͳΒͳͯ͘πϥ͍ • Go ͕ྲྀߦͬͯΔΒ͍͠ • ͡Ό͋ Mozilla ޷͖ͩ͠ Rust ʹ͠Α͏ ˡ?
  3. ຊ೔ͷྲྀΕ ▶ Rust Λ͞ΘͬͯΈΔ • rustup ͰπʔϧνΣʔϯΛΠϯετʔϧ • Cargo ͰϏϧυͯ͠ΈΔ

    ▶ Rust ͷಛ௃ͷ͝঺հ • ஫ҙ: ൃදऀ΋ૉਓͳͷͰ೉͍࣭͠໰͸ճ౴Ͱ͖·ͤΜ • https://doc.rust-lang.org/stable/book/ ΛಡΜͰ͍ͩ͘͞!! ▶ Debian ύοέʔδϯάΛࢼͯ͠Έͨ࿩
  4. Rust ͱ͸? ▶ Mozilla ͕։ൃͨ͠γεςϜϓϩάϥϛϯάݴޠ • Servo(ઈࢍ։ൃத) ͱ͍͏ϒϥ΢βΤϯδϯͷͨΊʹ։ൃ • ҆શੑɾฒߦੑʹ͍ͭͯߟ͑ΒΕͯઃܭ͞Ε͍ͯΔ

    • ੩తܕ෇͚ݴޠ • ֶशۂઢ͕πϥΠͱ͏Θ͞ ▶ Χχ? • Rust ϓϩάϥϚʔͷࣄΛ Rustacean(ϥετγΞϯ) ͱݺͿ • “Crustacean(ߕ֪ྨ)“ ͔Βདྷ͍ͯΔΒ͍͠ − ΦϥΠϦʔຊͷදࢴ͸ΦΦώϩόΦ΢ΪΨχ − ඇެࣜͳϚείοτ΋Χχ (Ferris ͍ͬͯ͏໛༷) ▶ Rust ͷϑΝΠϧͷ֦ுࢠ͸ .rs • Rust Ͱॻ͔ΕͨϓϩδΣΫτͷެࣜαΠτ͕ http://xxx.rs Ͱ͋Δ͜ͱ͕ଟ͍ • ࠃผίʔυτοϓυϝΠϯ .rs : ηϧϏΞ
  5. Πϯετʔϧ ▶ rustup ΛೖΕΔͷ͕ҰԠެࣜ • curl https://sh.rustup.rs -sSf | sh

    • ͋ͳͨͷ home dir ʹ৭ʑͱೖΓ·͢ ~/.cargo ▶ rustup ͷαϒίϚϯυͨͪ default σϑΥϧτͷπʔϧνΣʔϯΛ੾Γସ͑·͢ɻ • πʔϧνΣʔϯ: stable ͔ nightly ͔ಛఆͷόʔδϣϯΛࢦఆͰ͖Δ update ߋ৽Λ͔͚·͢ɻnightly Λ࢖͏৔߹͸ͪΐͪ͘ΐ͘࢖͏ • ͦͯͨ͠·ʹյΕΔ • յΕΔͱ͍ͬͯ΋ɺίϯύΠϥ͕͓͔͘͠ͳͬͨࣄ͸ͳ͍Ͱ͢ • 10 ೥લ͘Β͍ͷ sid ͷؾ෼ΛຯΘ͑·͢ completions γΣϧͷิ׬༻ͷίʔυΛు͘ (bash, zsh, fish, PowerShell, etc..)
  6. Debian ύοέʔδͰͷΠϯετʔϧ ▶ ΋ͪΖΜ Debian ͷύοέʔδ΋͋Δ • ϏϧυπʔϧͰ͋Δ cargo ͷύοέʔδΛೖΕΔͷ͕ΑΖ͍͔͠ͱ

    • ҰॹʹίϯύΠϥ (rustc) ΋ೖΓ·͢ % apt show cargo Package: cargo Version: 0.33.0-1 Priority: optional Section: rust Maintainer: Rust Maintainers <[email protected]> Installed-Size: 9,453 kB Depends: libc6 (>= 2.18), libcurl3-gnutls (>= 7.28.0), libgcc1 (>= 1:4.2), \ libgit2-27 (>= 0.26.0), libssh2-1 (>= 1.2.5), libssl1.1 (>= 1.1.0), \ zlib1g (>= 1:1.1.4), rustc (>= 1.24), binutils, gcc | clang | c-compiler Suggests: cargo-doc, python3 Homepage: https://crates.io/ Download-Size: 2,483 kB APT-Manual-Installed: yes APT-Sources: http://ftp.jp.debian.org/debian sid/main amd64 Packages
  7. Hello World (1/4) ▶ Rust ͷϓϩδΣΫτ͸ɺ cargo new Ͱ࡞Γ·͢ •

    --bin (ݱ default) ͔ --lib (چ default) Ͱύοέʔδͷछྨ΋ࢦఆͰ͖·͢ % cargo new hello Created binary (application) ‘hello‘ package ▶ ࣮ߦ͢ΔͱɺCargo.toml ͱ src/main.rs ͕Ͱ͖Δ % tree . ᵓᴷᴷ Cargo.toml ᵋᴷᴷ src ᵋᴷᴷ main.rs 1 directory, 2 files
  8. Hello World (2/4) ▶ ࣮͸ϓϩδΣΫτΛ࡞ͬͨ࣌఺Ͱ Hello World ͷ൒෼͕׬͍ྃͯ͠Δ • ੜ੒͞Εͨ

    src/main.rs ͷத਎ˣ 1 fn main() { 2 println!("Hello,␣world!"); 3 } ▶ ࣮ߦ͢Δʹ͸ cargo run • ࣮͸σόοάϏϧυͳͷͰɺ࠷దԽΛ͔͚Δʹ͸--release Λ͚ͭΔ % cargo run Compiling hello v0.1.0 (/path/to/hello) Finished dev [unoptimized + debuginfo] target(s) in 0.31s Running ‘target/debug/hello‘ Hello, world!
  9. Hello World (3/4) ▶ গ͠ίʔυΛݟͯΈΔ 1 fn main() { 2

    println!("Hello,␣world!"); 3 } ؔ਺ఆٛ fn Λ࢖͏ main ؔ਺ ໭Γ஋͸ॻ͔ͳ͍ println!() ࣮͸ؔ਺Ͱ͸ͳͯ͘ϚΫϩ (!͕෇͍ͯΔͷ͸ϚΫϩ)
  10. Hello World (4/4) ▶ Cargo.toml [package] name = "hello" version

    = "0.1.0" authors = ["Katsuki Kobayashi <[email protected]>"] edition = "2018" [dependencies] ▶ Cargo.lock (Ϗϧυ͢Δͱࣗಈੜ੒) # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "hello" version = "0.1.0"
  11. ͦΕ͡Ό͋ʜʜ ▶ ͪΐͬͱ৭ʑͱ Rust ͷߏจͱ͔ػೳΛ঺հ͠·͢ • ղΒͳ͍ or ΋ͬͱৄ͘͠ͱࢥͬͨΒ The

    book ΛಡΜͰ΋Β͑Ε͹ͱ − ޱ಄Ͱฉ͍ͯ΋Βͬͯ΋ྑ͍Ͱ͕͢ճ౴ʹځ͢ΔՄೳੑ͕ߴ͍Ͱ͢ ;-) • The book: https://doc.rust-lang.org/stable/book/ • ࣮ߦ؀ڥ͸ web Ͱ΍ͬͯ΋Βͬͯ΋ྑ͍͔΋Ͱ͢ − https://play.integer32.com/ ▶ ·͡Ίʹ޲͖߹͏ʹ͸݁ߏେม • ΧχຊͰҾ༻͞ΕͯΔ Quora ͷهࣄ • C++ͷຊΛݱࡏਐߦܗͰಡΜͰΔ਎ʹ͸͘͢͝ೲಘ − େମɺC++11 Ͱ͸͜͏ॻ͚Δ͔ΒͦΕ͕ਪ঑͍ͬͯ͏ͷ͕ Rust ͷจ๏ I’ve found that Rust has forced me to learn many of the things that I was slowly learning as "good practise" in C/C++ before I could even compile my code.
  12. ม਺એݴ (1/3) 1 let x = 1; 2 println!("x␣=␣{}", x);

    3 let x = 1.25; 4 println!("x␣=␣{}", x); 5 // x = 1; // error: expected floating-point number, 6 // found integer 7 // x = 1.5; // error: cannot assign twice to 8 // immutable variable ▶ ม਺ͷએݴ͸ let Ͱߦͳ͏ • ܕ͸ (Ұҙʹਪ࿦Ͱ͖ΔͳΒ) লུՄೳ • γϟυʔΠϯάՄೳ • ࢦఆ͕ͳ͚Ε͹ immutable ͳม਺ʹͳΔ
  13. ม਺એݴ (2/3) 1 let mut y: u32 = 1; 2

    y -= 1; 3 y -= 1; 4 println!("y␣=␣{}", y); ▶ ม਺ͷએݴ͸ let Ͱߦͳ͏ • ܕ͸ޙஔه๏ (ίϩϯͷޙΖʹ͚ͭΔ) • mutable ͳม਺ʹ͚ͨ͠Ε͹ mut ΩʔϫʔυΛ࢖͏ ▶ ͪͳΈʹɺ࣮ߦ͢ΔͱσόοάϏϧυͩͱ్தͰࢭ·Γ·͢ % cargo run Compiling variable v0.1.0 (/path/to/examples/variable) Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running ‘target/debug/variable‘ thread ’main’ panicked at ’attempt to subtract with overflow’, \ variable/src/main.rs:12:5 note: Run with ‘RUST_BACKTRACE=1‘ environment variable to \ display a backtrace.
  14. ม਺એݴ (3/3) ▶ ϦϦʔεϏϧυ (--release ෇͖) ͢Δͱ࠷ޙ·Ͱ࣮ߦ͢Δ • ΋ͪΖΜɺ݁Ռ͸͓͔͠ͳ͜ͱʹͳΔ %

    cargo run Compiling variable v0.1.0 (/path/to/examples/variable) Finished release [optimized] target(s) in 0.30s Running ‘target/release/variable‘ x = 1 x = 1.25 y = 4294967295
  15. جຊతͳܕ ੔਺ ූ߸ແ͠: u8, u16, u32, u64, usize ූ߸෇͖: i8,

    i16, i32, i64, isize ුಈখ਺఺ ୯ਫ਼౓: f32ɺഒਫ਼౓: f64 ϒʔϧ bool จࣈ char (Unicode ͷ 1 จࣈ) จࣈྻ String ▶ ͨͩ͠ɺจࣈྻϦςϥϧͷ str ͕͋ͬͯͱͯ΋΍΍͍͜͠ ഑ྻ [T; N] (T: ܕ, N: ཁૉ਺) ϕΫλʔ Vec<T> (T: ܕ) εϥΠε &[T] (T: ܕ)
  16. String ͱ str (1/2) ▶ C++ͷ std::string ͱ char ʹࣅ͍ͯΔ

    1 let a = "abcd".to_string(); // String::from("abcd"); ΋Մ 2 let b = &a[1..]; 3 let c = "zyxwv";
  17. String ͱ str (2/2) ▶ String ͸Մม௕ 1 let mut

    a = "abcd".to_string(); 2 // ^^^ 3 a.push_str("efg"); // OK 4 5 let mut c = "zyxwv"; 6 // no method named ‘push_str‘ found 7 // for type ‘&str‘ in the current scope 8 c.push_str("ut"); // Error!!
  18. ؔ਺ ▶ fn Ωʔϫʔυͱ -> τʔΫϯΛ࢖ͬͯॻ͘ 1 fn add(a: i32,

    b: i32) -> i32 { 2 return a + b; 3 } 4 5 fn main() { 6 println!("{}", add(1, 2)); 7 } % cargo run Compiling function v0.1.0 (/path/to/examples/function) Finished dev [unoptimized + debuginfo] target(s) in 0.20s Running ‘target/debug/function‘ 3
  19. ॴ༗ݖ (1/4) ▶ ੔਺ܕͱจࣈྻܕͷม਺Λෳ਺ͷม਺ʹ୅ೖͯ͠ΈΔ 1 let i0 = 1; 2

    let i1 = i0; 3 let i2 = i0; 4 5 let s0: String = "hoge".to_string(); 6 let s1 = s0; 7 let s2 = s0;
  20. ॴ༗ݖ (1/4) ▶ ੔਺ܕͱจࣈྻܕͷม਺Λෳ਺ͷม਺ʹ୅ೖͯ͠ΈΔ • Ͳ͏ͳΔͱࢥ͍·͢? 1 let i0 =

    1; 2 let i1 = i0; 3 let i2 = i0; 4 5 let s0: String = "hoge".to_string(); 6 let s1 = s0; 7 let s2 = s0;
  21. ॴ༗ݖ (2/4) ▶ จࣈྻܕͷํ͚ͩίϯύΠϧΤϥʔʹͳΔ • Rust Ͱ͸ɺ୅ೖɺؔ਺ͷҾ਺ɺؔ਺ͷ໭Γ஋Ͱॴ༗ݖ͕Ҡಈ͢Δ • ͨͩ͠ɺ੔਺౳ɺҰ෦ͷܕ͸ίϐʔʹͳΔ −

    ͦͷͨΊ i2 Ͱ͸Τϥʔʹͳ͍ͬͯͳ͍ − ίϐʔ͞ΕΔܕʹ͍ͭͯ͸ɺΤϥʔͰग़͍ͯΔ “Copy trait ” ͱ͍͏ͷ͕ϛι error[E0382]: use of moved value: ‘s0‘ --> ownership/src/main.rs:8:15 | 6 | let s0: String = "hoge".to_string(); | -- move occurs because ‘s0‘ has type ‘std::string::String‘, \ which does not implement the ‘Copy‘ trait 7 | let s1 = s0; | -- value moved here 8 | let s2 = s0; | ^^ value used here after move
  22. ॴ༗ݖ (3/4) ▶ ؔ਺ͷҾ਺΋ବ໨ͳͷͰҎԼ΋Ξ΢τ 1 fn consume(_s: String) {} 2

    // தུ 3 let h: String = "Hello␣World".to_string(); 4 consume(h); 5 let hh = h; 12 | let h: String = "Hello World".to_string(); | - move occurs because ‘h‘ has type ‘std::string::String‘, \ which does not implement the ‘Copy‘ trait 13 | consume(h); | - value moved here 14 | let hh = h; | ^ value used here after move
  23. ॴ༗ݖ (4/4) ▶ ٯʹؔ਺ͷ໭Γ஋ͷॴ༗ݖΛݺͼݩʹ౉ͤΔ 1 fn generate(i: i32) -> Vec<i32>

    { 2 let mut v = Vec::new(); 3 v.push(i); 4 return v; 5 } 6 // ུ 7 let v1 = generate(10); 8 let mut v2 = generate(100); 9 v2.push(101); 10 println!("v1:␣{:?}", v1); // v1: [10] 11 println!("v2:␣{:?}", v2); // v2: [100, 101]
  24. ࢀর, आ༻ (1/2) ▶ ॴ༗ݖΛ౉ͣ͞ʹ஋Λ࢖͏ʹ͸ࢀরΛ࢖͏ • Rust Ͱ͸ʮआ༻ʯͱ΋ݴ͏ • C++ͱ͓ͳ͘͡ɺ

    “&” Λ࢖͏ • C++ͱҧ͍ − आ༻͢Δଆ (ࢀর͞ΕΔଆ) ʹ “&” Λ෇͚Δ − ؔ਺ͷݺͼग़͠ݩͱݺͼग़͠ઌ྆ํʹ “&” ͕ඞཁ 1 fn consume(_s: &String) {} 2 // ུ 3 let s0: String = "hoge".to_string(); 4 let s1 = &s0; 5 let s2 = &s0; 6 7 let h: String = "Hello␣World".to_string(); 8 consume(&h); 9 let hh = h;
  25. ࢀর, आ༻ (2/2) ▶ ࢀরͷղܾʹ͸ “*” Λ࢖͏ 1 let i0

    = 5; 2 let i1 = &i0; 3 4 println!("i0:␣{},␣i1:␣{}", i0, *i1); ▶ Ͱ΋ɺؔ਺Ͱ࢖͏৔߹ͩͬͨΓɺ৭ʑͳ৔໘ͰলུͰ͖ͨΓ͢Δ 1 fn catlength(a: &String, b: &String) -> usize { 2 return a.len() + b.len(); 3 } 4 // ུ 5 let s0 = "hoge".to_string(); 6 let s1 = "fuga".to_string(); 7 println!("{}", catlength(&s0, &s1));
  26. ϥΠϑλΠϜ (1/6) ▶ C ݴޠͱ͓ͳ͘͡ Rust ͷม਺ʹ͸είʔϓ͕͋Δ (GC ͱ͔͸ͳ͍) 1

    { 2 let a = 0; 3 } // ͜͜Ͱυϩοϓ 4 println!("{}", a); error[E0425]: cannot find value ‘a‘ in this scope --> lifetime/src/main.rs:5:20 | 5 | println!("{}", a); | ^ not found in this scope
  27. ϥΠϑλΠϜ (2/6) ▶ ࢀর͍ͯͨ͠৔߹ɺίϯύΠϧ࣌ʹౖΒΕΔ • C/C++ͰΑ͘΍Δղ์ࡁΈͷϝϞϦΞΫηεͱ͔͕ίϯύΠϧ࣌ʹൃݟͰ͖Δ!! 1 let r; 2

    { 3 let b = 0; 4 r = &b; 5 } 6 println!("{}", r); error[E0597]: ‘b‘ does not live long enough --> lifetime/src/main.rs:11:9 | 11 | r = &b; | ^^^^^^ borrowed value does not live long enough 12 | } | - ‘b‘ dropped here while still borrowed 13 | println!("{}", r); | - borrow later used here
  28. ϥΠϑλΠϜ (3/6) ▶ ͞Βʹ΍΍͍͜͠ͷ͕ؔ਺ͰɺҎԼ͸ΤϥʔʹͳΔ • ͞ΒΓͱॻ͍ͯ·͕͢ɺηϛίϩϯΛൈ͔͢ͱ஋Λ࡞Γ·͢ − ͦͷͨΊɺ x ΍

    y ͷޙΖʹηϛίϩϯ͕ͳ͍ − if ࣜ ͷޙΖʹ΋ηϛίϩϯ͕ͳ͍ 1 fn longest(x: &str, y: &str) -> &str { 2 if x.len() > y.len() { 3 x 4 } else { 5 y 6 } 7 }
  29. ϥΠϑλΠϜ (4/6) 1 fn longest(x: &str, y: &str) -> &str

    { 2 if x.len() > y.len() { 3 x 4 } else { 5 y 6 } 7 } error[E0106]: missing lifetime specifier --> lifetime/src/main.rs:1:33 | 1 | fn longest(x: &str, y: &str) -> &str { | ^ expected lifetime parameter | = help: this function’s return type contains a borrowed value, \ but the signature does not say whether it is borrowed from ‘x‘ or ‘y‘
  30. ϥΠϑλΠϜ (5/6) error[E0106]: missing lifetime specifier --> lifetime/src/main.rs:1:33 | 1

    | fn longest(x: &str, y: &str) -> &str { | ^ expected lifetime parameter | = help: this function’s return type contains a borrowed value, \ but the signature does not say whether it is borrowed from ‘x‘ or ‘y‘ ▶ ໰୊͸ͳʹ͔? • ࣮ߦ͢Δ·Ͱ x ͱ y (ͲͪΒ΋ࢀর) ͷͲͪΒΛฦ͔͢Θ͔Βͳ͍ • ໭Γ஋ͷϥΠϑλΠϜ͕Ͳ͏ͳΔ͔Θ͔Βͳ͍ͷͰɺͦͷޙͷॲཧ͕νΣοΫͰ͖ͳ͍ ▶ Μ͡ΌͲ͏͢Δͷ? • ίϯύΠϥౖ͕͍ͬͯΔ௨Γɺlifetime parameter Λॻ͚͹ OK • جຊతʹ Rust ͷίϯύΠϥͷΤϥʔϝοηʔδ͸਌੾Ͱ͢ − Ұ෦ͷίϯύΠϥ͕ΧΦεͳ͚ͩ΋͠Ε·ͤΜ͕ʜʜͶ͐ɺgcc ͞Μ
  31. ϥΠϑλΠϜ (6/6) ▶ ҎԼͷΑ͏ʹॻ͘ඞཁ͕͋Δ • ੜଘظؒΛ ’a ͱ͢Δ − ه߸͸׳ྫతʹ͸ద౰ͳ໛༷

    • ໭Γ஋͸ x, y ͷ୹͍ํͷੜଘظؒΛ࣋ͭඞཁ͕͋Δ • fn longest<’a, ’b>(x: &’a str, y: &’b str) -> &’a str ͱ΋ॻ͚Δ͕ y ͷੜଘظ͕ؒ ’a Ͱͳ͍ͨΊΤϥʔʹͳΔ 1 fn longest<’a>(x: &’a str, y: &’a str) -> &’a str { 2 if x.len() > y.len() { 3 x 4 } else { 5 y 6 } 7 }
  32. ߏ଄ମ (1/2) ▶ Rust ʹ͸ class ͸ͳ͍ • ૉ௚ʹ (?)

    ߏ଄ମΛ࢖͏ • ஋ͷએݴ࣌͸֤ཁૉͷ໊લ͕ඞཁ (·ͬͨ͘ಉ໊ͷม਺ͰॳظԽ͢Δͱ͖ͷΈলུՄ) • ຊ೔͸ѻ͍·ͤΜ͕ɺϥΠϑλΠϜ΋བྷΜͰ͘Δ 1 struct Point { 2 x: f64, 3 y: f64, 4 } 5 // ུ 6 let _p0 = Point { x: 1.0, y: 1.0 };
  33. ߏ଄ମ (2/2) ▶ ߏ଄ମ͚ͩͲɺؔ਺Λੜ΍ͤΔΑ ww • ࠷ॳͷҾ਺͸ self(஋Λมߋ͍ͨ͠৔߹͸ mut Λ෇͚Δ)

    1 struct Point { 2 x: f64, 3 y: f64, 4 } 5 6 impl Point { 7 fn abs(&self) -> f64 { 8 (self.x * self.x + self.y * self.y).sqrt() 9 } 10 } 11 12 fn main() { 13 let p0 = Point { x: 1.0, y: 1.0 }; 14 println!("{}", p0.abs()); // => 1.4142135623730951 15 }
  34. δΣωϦοΫ ▶ ߏ଄ମɺؔ਺౳Λ generic ʹ͢Δ͜ͱ͕Ͱ͖Δ • C++ͷςϯϓϨʔτɺJava ͷδΣωϦΫεతͳ΋ͷ 1 struct

    GenPoint<T> { 2 x: T, 3 y: T, 4 } 5 // ུ 6 let _p1 = GenPoint::<i32> { x: 1, y: 1 }; 7 let _p2 = GenPoint { x: 1, y: 1 }; 8 let _p3 = GenPoint { x: 1.5, y: 2.0 }; ▶ GenPoint<T, U> ͱͯ͠ɺ y Λ U ͱ͢Δ͜ͱ΋Ͱ͖Δ
  35. Trait (1/5) ▶ Java ͱ͔ Go ͷΠϯλʔϑΣʔεతͳ΋ͷ΋͋Δ -> Trait(τϨΠτ) •

    ͖͞΄Ͳग़͖ͯͨ Copy trait ΋ίϨ ▶ trait ͷఆٛ͸ҎԼͷΑ͏ʹ trait ΩʔϫʔυͰ࡞Δ • duck ͸ walk ͯ͠ quack Ͱ͖Δ΋ͷ 1 trait Duck { 2 fn walk(&self); 3 fn quack(&self); 4 }
  36. Trait (2/5) ▶ ࣮૷͸ҎԼͷΑ͏ʹ 1 struct RealDuck {} 2 3

    impl Duck for RealDuck { 4 fn walk(&self) { 5 println!("duck␣walking"); 6 } 7 8 fn quack(&self) { 9 println!("quack") 10 } 11 }
  37. Trait (3/5) ▶ ಉ༷ʹ Dog ΋࣮૷͢Δ 1 struct Dog {}

    2 3 impl Duck for Dog { 4 fn walk(&self) { 5 println!("dog␣walking"); 6 } 7 8 fn quack(&self) { 9 println!("bow") 10 } 11 }
  38. Trait (4/5) ▶ ͦ͏͢ΔͱɺҎԼͷΑ͏ʹ Duck ΛҾ਺ʹͨؔ͠਺ test_duck() ʹ RealDuck ͱ

    Dog ͷͲͪΒ΋౉͢͜ͱ͕Ͱ͖Δ 1 fn test_duck(duck: &Duck) { 2 duck.walk(); 3 duck.quack(); 4 } 5 6 fn main() { 7 let duck = RealDuck {}; 8 let dog = Dog {}; 9 10 test_duck(&duck); 11 test_duck(&dog); 12 }
  39. Trait (5/5) ▶ ෳ਺ͷ Trait Λ࣮૷ͨ͠ܕΛཁٻ͢Δ͜ͱ΋Ͱ͖Δ • pub fn notify(item:

    impl Summary + Display) { − Summary ͱ Display Λಉ࣌ʹ࣮૷ͨ͠ܕ ▶ ಡΈਏ͍ͷͰɺҎԼͷॻࣜ΋͋Δ • pub fn notify<T: Summary + Display>(item: T) { ▶ ͞Βʹ͜Μͳॻࣜ΋ʜʜ 1 fn some_function<T, U>(t: T, u: U) -> i32 2 where T: Display + Clone, 3 U: Clone + Debug 4 {
  40. enum (1/5) ▶ Rust ͷ enum ͸ ৭ʑͱ͓͔͍͠ ૬౰ʹڧྗ ▶

    C ݴޠͷΑ͏ͳ enum ͸΋ͪΖΜ࡞ΕΔ 1 enum Fruits { 2 Apple, 3 Banana, 4 Orange, 5 Peach, 6 } 7 // ུ 8 let _hoge = Fruits::Apple;
  41. enum (2/5) ▶ enum ஋ͷதʹ஋Λ࣋ͭ͜ͱ͕Ͱ͖Δ • ͔͠΋ɺܕ΋ݸ਺΋ࣗ༝ࣗࡏ • (u8, u8,

    u8, u8) ͸λϓϧ 1 enum IpAddr { 2 V4((u8, u8, u8, u8)), 3 V6(String), 4 } 5 // ུ 6 let v4_addr = IpAddr::V4((127, 0, 0, 1)); 7 let v6_addr = IpAddr::V6("::1".into()); ▶ ͳ͓ɺenum ʹ΋ϝιουΛੜ΍ͤ·͢ www • struct ͷͱ͖ͱಉ͘͡ɺimpl ΩʔϫʔυΛ࢖͏
  42. enum (3/5) ▶ ஋Λ࣋ͨͤͨ enum ͸ match Λ࢖ͬͯऔΓग़͢͜ͱ͕Ͱ͖Δ • C

    ݴޠͷ switch จͷ default తͳͷ͸ “_ =>” ͱॻ͘ 1 fn extract_addr(addr: &IpAddr) { 2 match addr { 3 IpAddr::V4(a) => { 4 println!("{}.{}.{}.{}", a.0, a.1, a.2, a.3); 5 } 6 IpAddr::V6(a) => { 7 println!("{}", a); 8 } 9 } 10 } 11 // ུ 12 extract_addr(&v4_addr); // => 127.0.0.1 13 extract_addr(&v6_addr); // => ::1
  43. enum (4/5) ▶ λϓϧܕϰΝϦΞϯτɺߏ଄ମܕϰΝϦΞϯτͳΜͯ΋ͷ΋ʜʜ • ΍͸Γɺmatch Λ࢖ͬͯऔΓग़͢ ▶ λϓϧܕϰΝϦΞϯτͷྫ 1

    enum RoughTime { 2 InThePast(TimeUnit, u32), 3 JustNow, 4 InTheFuture(TimeUnit, u32), 5 } 6 // ུ 7 match &t { 8 RoughTime::InTheFuture(_, t) => { 9 println!("{}", t); 10 }
  44. enum (5/5) ▶ ߏ଄ମܕϰΝϦΞϯτͷྫ 1 enum Shape { 2 Sphere

    { center: Point3d, radius: f32 }, 3 Cuboid { corner1: Point3d, corner2: Point3d }, 4 } 5 // ུ 6 match &u { 7 Shape::Cuboid { 8 corner1: c1, 9 corner2: c2, 10 } => { 11 println!("{:?}", c1); 12 } ▶ ศར͕ͩɺ΍Γ͗͢ΔͱܕͷαΠζ͕ແବʹେ͖͘ͳΔ • ࠷େαΠζͷϰΝϦΞϯτʹ߹Θ͞ΔͨΊ • େ͖ͳϰΝϦΞϯτΛώʔϓʹஔ͚ΔΑ͏ʹ͢Δ Box ܕΛ༻͍Δ • Box ܕʹ͍ͭͯ͸ຊ೔͸ѻ͍·ͤΜ!!
  45. Option<T>ͱ Result<T,E> (1/2) ▶ Rust ͷඪ४తͳܕ ▶ ఆٛ͸ҎԼͷΑ͏ʹͳ͍ͬͯΔ 1 pub

    enum Option<T> { 2 None, 3 Some(T), 4 } 5 6 pub enum Result<T, E> { 7 Ok(T), 8 Err(E), 9 } ▶ Option<T> • ஋͕ͳ͍Մೳੑ͕͋ΔࣄΛࣔ͢ (nullptr ͷ୅ΘΓ) ▶ Result<T,E> • ࣦഊ͢ΔՄೳੑ͕͋ΔࣄΛࣔ͢ (ྫ֎ͷ୅ΘΓ)
  46. Option<T>ͱ Result<T,E> (2/2) ▶ ҎԼͷΑ͏ͳײ͡ͰΤϥʔ൑ఆ͢Δ • ৭ʑͱศརͳؔ਺΍ԋࢉࢠ͕͋Γ·͢. (?ԋࢉࢠ, expect(), unwrap())

    1 let i = match env::args().nth(1) { 2 None => { 3 panic!("no␣arguments"); 4 } 5 Some(arg) => match arg.parse::<i32>() { 6 Ok(fig) => fig, 7 Err(e) => { 8 panic!("error:␣{}", e); 9 } 10 }, 11 }; 12 13 println!("i:␣{}", i);
  47. Crate (1/3) ▶ Rust ͷϓϩάϥϜ͸ΫϨʔτͱݺ͹ΕΔ୯Ґͷ૊Έ߹ΘͤͰߏ੒͞ΕΔ • ৄࡉʹ͍ͭͯ͸ຊ೔͸লུ͢Δͱͯ͠ʜʜ ▶ crates.io •

    The Rust community’s crate registry ▶ ࢖͍ํ • Cargo.toml ͷ [dependencies] ʹɺcrates.io ʹॻ͔Ε͍ͯΔࣜΛೖΕΕ͹ OK • ͜͜ʹ git ͷϦϙδτϦΛͭͬ͜Ήࣄ΋Ͱ͖Δ ▶ ͜͜Ͱ͸ɺΦϓγϣϯղੳͷ crate ͷ clap Λ࢖ͬͨྫΛ঺հ͠·͢ • -n Φϓγϣϯ͚ͩ͋Δ echo ίϚϯυ΋Ͳ͖ [dependencies] clap = "2.32.0"
  48. Crate (2/3) ▶ Rust 2018 ͷલ·Ͱ͸ɺ extern crate clap; ͱ͢Δඞཁ͕͋ͬͨ

    • Cargo.toml ͱ৑௕͔ͩͬͨΒ (?) ෆཁʹ 1 use clap::{App, Arg}; 2 3 fn main() { 4 let m = App::new("echo") // ίϚϯυ໊ 5 .arg(Arg::with_name("STRING").multiple(true)) // ෳ਺ͷҾ਺ 6 .arg( // ’-n’ Λఆٛ 7 Arg::with_name("n") 8 .short("n") 9 .help("do␣not␣output␣the␣trailing␣newline"), 10 ) 11 .get_matches(); // ࣮ߦ 12 // ଓ͘
  49. Crate (3/3) 1 // ଓ͖ 2 let out = match

    m.values_of("STRING") { 3 // ˣ஍ຯʹΠςϨʔλΛ࢖༻ 4 Some(v) => v.collect::<Vec<&str>>().join("␣"), 5 None => "".into(), 6 }; 7 8 print!("{}", out); 9 10 if !m.is_present("n") { 11 println!(""); // ’-nΦϓγϣϯ͕ͳ͚Ε͹վߦ’ 12 } 13 }
  50. จ๏ͱ͔ʹ͍ͭͯ͸Ҏ্!! ▶ ຊ೔·͓ͬͨ͘఻͑Ͱ͖ͳ͔ͬͨ಺༰ • Ϋϩʔδϟʔ • ΠςϨʔλʔ • εϚʔτϙΠϯλ •

    ςετ − Rust ͸ϓϩάϥϜͱಉ͡ϑΝΠϧʹςετΛॻ͍ͨΓɺίϝϯτͷαϯϓϧϓϩάϥϜͷςετ ͱ͔΋Ͱ͖Δ ▶ ڵຯ͕͋Ε͹ɺ The Book Λ͓ಡΈ͍ͩ͘͞ ▶ ࠶ܝ: Ϗϧυ͢Δͱ Cargo.lock ͱ͍͏ϑΝΠϧ͕ੜ੒͞ΕΔ • Cargo.toml ͸ͬ͘͟Γͱͨ͠ґଘΛखಈͰ࡞੒ − όʔδϣϯ൪߸΋ϝδϟʔόʔδϣϯ͚ͩهड़Ͱ͖Δ • Cargo.lock ͸׬શͳόʔδϣϯ΍ϋογϡ஋Λ࣋ͬͯ Cargo ͕Ϗϧυ࣌ʹࣗಈͰ࡞੒ − Ξοϓσʔτ͚ͨ͠Ε͹ cargo update Λ࣮ߦ
  51. Debian ύοέʔδʹͯ͠ΈΔ ▶ Ұ൪؆୯ͳํ๏ : cargo-deb • A cargo subcommand

    that generates Debian packages from information in Cargo.toml − GitHub − Ξφ΢ϯε@users.rustlang.org • Πϯετʔϧํ๏ − cargo install cargo-deb : cargo ͷαϒίϚϯυͱͯ͠ೖΔ − deb ͸ʜʜͳ͍ʜʜ!! • ໰୊఺ − ެࣜʹ͸ͱͯ΋ೖΒͳ͍ deb Λు͘ − ୯ҰόΠφϦͷϓϩδΣΫτʹ͔͠ରԠ͍ͯ͠ͳ͍ − ͔ͩΒ deb ʹͳͬͱΒΜͷ͔ʜʜ • ·͊ɺ͍͑΍ͱ/usr/bin ʹೖΕ͍ͨͳΒΞϦ͔΋Ͱ͕͢ʜʜ
  52. ਅ໘໨ʹ Debian ύοέʔδʹͯ͠ΈΔ ▶ Debian Rust packaging team • https://wiki.debian.org/Teams/RustPackaging

    ▶ crates.io ʹ͋Δ΋ͷʹ͍ͭͯ͸ debcargo ͕͍͍ײ͡ʹ΍ͬͯ͘ΕΔΒ͍͠ • ࣮ࡍʹ debcargo package ripgrep Λ͢Δͱ ripgrep ͷ deb ͕࡞ΒΕΔ • ͱ͜Ζ͕ɺ͜ͷ debcargo ͞Μɺ crates.io ʹΞοϓ͞Ε͍ͯΔ෺͔͠ deb ʹͯ͘͠Εͳ͍໛༷ʜʜ ▶ ͜ΕҎ߱Ͱ͸ɺઌఔͷ clap ͷαϯϓϧͷ deb ࡞੒ʹ௅ઓ͠·͢ • ํ਑ͱͯ͠ɺdebcargo Ͱ΋࢖͏ dh-cargo Λ࢖͏ • https://github.com/rarewin/clap-test ʹιʔεஔ͍ͯ·͢
  53. dh_make ͢Δ % dh_make -s -p rust-clap-test_0.1.0 --createorig Maintainer Name

    : Katsuki Kobayashi Email-Address : [email protected] Date : Sat, 23 Mar 2019 18:03:48 +0900 Package Name : rust-clap-test Version : 0.1.0 License : blank Package Type : single Are the details correct? [Y/n/q] Currently there is not top level Makefile. This may require additional tuning Done. Please edit the files in the debian/ subdirectory now. ▶ debcargo Λ࢖͏ͱɺύοέʔδ໊ʹ͸ rust- ΋͘͠͸ librust- ͕ suffix ͱͯ͠෇͘໛༷
  54. dh-cargo Λ࢖͏Α͏ʹ͢Δ ▶ ͻͱ·ͣҎԼΛͯ͠ΈΔ • debian/rules ʹΦϓγϣϯΛ௥Ճ • debian/control ͷ

    Build-Depends ʹ dh-cargo/librust-clap-dev ΛೖΕΔ %: dh $@ --buildsystem cargo ▶ ͱΓ͋͑ͣ debuild-pbuilder ͯ͠ΈΔ % debuild-pbuilder -> Attempting to satisfy build-dependencies -> Creating pbuilder-satisfydepends-dummy package Package: pbuilder-satisfydepends-dummy Version: 0.invalid.0 ... (snip) ... dh_autoreconf -O--buildsystem=cargo dh_auto_configure -O--buildsystem=cargo cp: ’./debian/cargo-checksum.json’ Λ stat Ͱ͖·ͤΜ: \ ͦͷΑ͏ͳϑΝΠϧ΍σΟϨΫτϦ͸͋Γ·ͤΜ
  55. cargo-checksum.json? ▶ RustPackagingTeam • upstream ͷ crate ͷνΣοΫαϜΛؚΊΔ • /usr/share/cargo/registry

    Λ࢖͏ͨΊʹ࢖͏ − deb ͷϏϧυʹωοτϫʔΫ࢖ͬͪΌବ໨͔ͩΒͱࢥΘΕ • ˢͷ࢓૊Έ͸ cargo-vendor Λར༻͍ͯ͠Δ − cargo-vendor ͸ϩʔΧϧͷιʔεΛ cargo ͕֎෦ crate ͱͯ͠ѻ͏ͨΊͷ࢓૊ΈΛఏڙ ▶ ͱ͔ɺΘΓͱෆ਌੾ʹॻ͍ͯ͋Δ (࡞Γํͷղઆͱ͔ͳ͍) ΜͰ͕͢ʜʜ
  56. cargo-checksum.json? ▶ RustPackagingTeam • upstream ͷ crate ͷνΣοΫαϜΛؚΊΔ • /usr/share/cargo/registry

    Λ࢖͏ͨΊʹ࢖͏ − deb ͷϏϧυʹωοτϫʔΫ࢖ͬͪΌବ໨͔ͩΒͱࢥΘΕ • ˢͷ࢓૊Έ͸ cargo-vendor Λར༻͍ͯ͠Δ − cargo-vendor ͸ϩʔΧϧͷιʔεΛ cargo ͕֎෦ crate ͱͯ͠ѻ͏ͨΊͷ࢓૊ΈΛఏڙ ▶ ͱ͔ɺΘΓͱෆ਌੾ʹॻ͍ͯ͋Δ (࡞Γํͷղઆͱ͔ͳ͍) ΜͰ͕͢ʜʜ % apt source ripgrep % cat rust-ripgrep-0.10.0/debian/cargo-checksum.json {"package":"Could not get crate checksum","files":{}} ▶ ͍ͬͨΜΘ͢Ε·͢ • ͳΜͱɺtouch debian/cargo-checksum.json ͰϏϧυ͕ਐΉ • ͜ͷ “could not get crate checksum” ͸ debcargo ͷΤϥʔΈ͍ͨͰ͢
  57. ґଘ஍ࠈͱҋͱ (1/4) ▶ Ϗϧυ͕ਐΉΑ͏ʹͳͬͨ͸Α͍͕ debian cargo wrapper: running subprocess ([’env’,

    ’RUST_BACKTRACE=1’, \ ’/usr/bin/cargo’, ’-Zavoid-dev-deps’, ’build’, ’--verbose’, ’--verbose’, \ ’-j4’, ’--target’, ’x86_64-unknown-linux-gnu’],) {} error: failed to select a version for the requirement \ ‘textwrap = "= 0.10.0"‘ candidate versions found which didn’t match: 0.11.0 location searched: directory source ‘/path/to/clap-test/debian/cargo_registry‘ \ (which is replacing registry ‘https://github.com/rust-lang/crates.io-index‘) required by package ‘clap v2.32.0‘ ▶ Կނ͔ textwrap ͷόʔδϣϯ໰୊Ͱࣦഊʜʜ • clap ͸ 0.10.0 ͷ textwrap Λཁٻ • ݱࡏͷ debian sid/buster ͷ librust-textwrap-dev ͸ 0.11.0
  58. ґଘ஍ࠈͱҋͱ (2/4) ▶ ͔͠͠ͳͥ? • ripgrep ΋ clap ʹґଘ͍ͯ͠ΔͷʹϏϧυͰ͖͍ͯΔ ▶

    github ͷ ripgrep ͷ tar ͱ deb ͷ ripgrep ͷιʔεΛൺֱͯ͠ΈΔ • ඍົʹࠩ෼͕͋Δʜʜ • Ͳ͏΍Βɺcrates.io ͔Β࣋ͬͯ͘ΔͱɺCargo.toml ͕ฤू͞Ε (Cargo.toml ʹίϝϯτ ͋Γ)ɺCargo.lock ͕࡟আ͞ΕΔ໛༷ (ͬͪ͜͸͋΍;΍) % grep textwrap Cargo.lock "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", name = "textwrap" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" ▶ ͏ʔΉʜʜ
  59. ґଘ஍ࠈͱҋͱ (3/4) % rm Cargo.lock % debuild-pbuilder ... (snip) ...

    Compiling textwrap v0.11.0 Running ‘rustc --crate-name textwrap.... ... (snip) ... Finished running lintian. ▶ ͳΜͱɺCargo.lock Λফͨ͠ΒϏϧυͰ͖ͯ͠·ͬͨʜʜ • debian/cargo_registry ҎԼʹґଘ crate ͷϩʔΧϧ % ls -lh debian/cargo_registry/textwrap-* ... debian/cargo_registry/textwrap-0.11.0 \ -> /usr/share/cargo/registry/textwrap-0.11.0/
  60. ґଘ஍ࠈͱҋͱ (4/4) ▶ Α͘Α͘ௐ΂ͯΈΔͱɺclap ͷ Cargo.toml ͕ɺcrates.io ొ࿥࣌ʹґଘؔ܎͕ม ߋ͞Ε͍ͯΔ໛༷ʜʜ %

    grep -A 1 dependencies.textwrap debian/cargo_registry/clap-2.32.0/Cargo.toml [dependencies.textwrap] version = ">= 0.10, < 0.12" ▶ GitHub ʹ͋Δ clap ͷίʔυͩͱҎԼ [dependencies] bitflags = "1.0" unicode-width = "0.1.4" textwrap = "0.10.0" ▶ Ͳ͏͍͏ج४Ͱมߋ͞Εͨͷ͔͸·ͩௐ΂͓ͯΓ·ͤΜʜʜ • debian ͷ librust-*ͳύοέʔδͨͪ͸ͲͷΑ͏ͳج४Ͱߋ৽͞Ε͍ͯΔͷͩΖ͏͔ʜʜ
  61. ͱʹ΋͔͘ʹ΋ (1/2) ▶ deb ͸Ͱ͖·ͨ͠!! • ͍΍ɺlintian ͷܯࠂ΋Τϥʔ΋औͬͯͳ͍Ͱ͕͢!! % dpkg

    -I rust-clap-test_0.1.0-1_amd64.deb new Debian package, version 2.0. size 258160 bytes: control archive=648 bytes. 360 όΠτɺ 11 ߦ control 285 όΠτɺ 4 ߦ md5sums Package: rust-clap-test Version: 0.1.0-1 Architecture: amd64 Maintainer: Katsuki Kobayashi <[email protected]> Installed-Size: 770 Depends: libc6 (>= 2.18), libgcc1 (>= 1:4.2) Section: unknown Priority: optional Homepage: <insert the upstream URL, if relevant> Description: <insert up to 60 chars description> <insert long description, indented with spaces>
  62. ͱʹ΋͔͘ʹ΋ (2/2) % dpkg -c rust-clap-test_0.1.0-1_amd64.deb drwxr-xr-x root/root 0 2019-03-23

    18:06 ./ drwxr-xr-x root/root 0 2019-03-23 18:06 ./usr/ drwxr-xr-x root/root 0 2019-03-23 18:06 ./usr/bin/ -rwxr-xr-x root/root 776600 2019-03-23 18:06 ./usr/bin/clap-test drwxr-xr-x root/root 0 2019-03-23 18:06 ./usr/share/ drwxr-xr-x root/root 0 2019-03-23 18:06 ./usr/share/doc/ drwxr-xr-x root/root 0 2019-03-23 18:06 ./usr/share/doc/rust-clap-test/ -rw-r--r-- root/root 197 2019-03-23 18:06 ./usr/share/doc/rust-clap-test/READ -rw-r--r-- root/root 190 2019-03-23 18:06 ./usr/share/doc/rust-clap-test/chan -rw-r--r-- root/root 1693 2019-03-23 18:06 ./usr/share/doc/rust-clap-test/copy ▶ ͋Ε͚ͩͷϓϩάϥϜͰ 800KB ͔͔ͪ͊͘ʜʜ
  63. ͱ͏ͱͭʹ·ͱΊ!! ▶ ݁ہ Rust ͳ deb Λ࡞Δʹ͸ • crates.io ʹొ࿥ͯ͠

    debcargo Λϕʔεʹͭ͘Δ͕ެࣜख๏ • ҰԠɺϩʔΧϧͰ dh-cargo Λ͔ͭͬͯ΋ରԠ͸Ͱ͖ͦ͏ • debcargo Λ git ϦϙδτϦʹରԠͤͯ͞΋ྑͦ͞͏͚ͩͲ Cargo.toml/Cargo.lock ·Θ Γͷ໰୊͸͋Γ? ▶ ͦ΋ͦ΋ґଘؔ܎େৎ෉? • ࠓճ͸ௐ΂͖Εͳ͔ͬͨͰ͕͢ɺdeb ͷ librust-*ύοέʔδ·ΘΓ͸݁ߏ͋Ϳͳ͍ڮΛ ౉͍ͬͯΔ͔΋ʜʜ? • ͜ͷ͍͋ͩ (2 ݄) ʹ ripgrep ͕ϏϧυͰ͖ͳ͍ͱ͍͏ buster ͷόά͕͋ͬͨ ͠ʜʜ#920958 ▶ ͦΕͰ΋ Rust ͸ྑ͍ݴޠ • গʑֶशۂઢ͕ΞϨ͚ͩͲɺ͜Ε͔Βྲྀߦ͍ͬͯ͘ʹҧ͍ͳ͍ • Debian Ͱ΋ίϛϡχςΟ͕׆ൃʹͳΕ͹Α͍ͳ͊ (ଞਓࣄ) • ॗʑͱ debcargo ͸։ൃ͞Ε͍ͯΔΑ͏Ͱɺઌि buster ʹ͸ೖΒͳ͍͚Ͳ post-install Ͱ test ͕͖ΔΑ͏ʹͳͬͨΓ͍ͯ͠Δ໛༷
  64. Ͳ͔ͬʹૠೖ༧ఆͷϝϞ ▶ Rust ͷϑΝΠϧͷ֦ுࢠ͸ .rs • Rust Ͱॻ͔ΕͨϓϩδΣΫτͷެࣜαΠτ͕ http://xxx.rs Ͱ͋Δ͜ͱ͕ଟ͍

    • ࠃผίʔυτοϓυϝΠϯ .rs : ηϧϏΞ ▶ rust-fmt ͱ͍͏πʔϧ͕͋Δ • gofmt ͱ͔ autopep8 ͱ͔ clang-format తͳπʔϧ ▶ Podcast (Rebuild.fm?) Ͱ୭͔͕ݴͬͯͨ • Go: C++͕ݏ͍Ͱۦஞ͍ͨ͠ • Rust: C++͕େ޷͖͚ͩͲਏ͍ͷͰͳΜͱ͔͍ͨ͠ ▶ Rustacean • LISPer, Pythonista, Rubyist, Gopher, TeXnician తͳ • “crustaceans” : ߕ֪ྨ − ΦϥΠϦʔຊͷදࢴ͸ΦΦώϩόΦ΢ΪΨχ − ඇެࣜͳϚείοτ΋Χχ (Ferris ͍ͬͯ͏໛༷)
  65. Ͳ͔ͬʹૠೖ༧ఆͷϝϞ ▶ ͱΓ͋͑ͣύοέʔδʹ͢Δʹ͸ • dh_make Λ࣮ߦ • debian/rules ͷ dh

    ͷҾ਺ʹ--buildsystem cargo Λ௥Ճ cp: ’./debian/cargo-checksum.json’ Λ stat Ͱ͖·ͤΜ: \ ͦͷΑ͏ͳϑΝΠϧ΍σΟϨΫτϦ͸͋Γ·ͤΜ ▶ Ή͎? • cargo-vendor Ͱ֤ crate ͷ checksum ͸࡞ΕΔ͚Ͳɺmain.rs ͳΞϓϦ͸Ͳ͏ͨ͠Β?