Buka menu utama

Rust ialah sebuah bahasa pengaturcaraan yang dibangunkan oleh Mozilla. Berbeza dengan bahasa pengaturcaraan moden lain, ia tidak menggunakan sebarang pengutip sampah automatik, sebaliknya ia menggunakan konsep pemerolehan sumber adalah pengawalan (RAII).

Rust
Rust programming language black logo.svg
Muncul pada7 Julai 2010; 9 tahun yang lalu (2010-07-07)
Direka olehGraydon Hoare
PembangunThe Rust Project
Lepasan stabil1.39.0[1] (7 November 2019; 27 hari yang lalu (2019-11-07))
Disiplin penjenisanDiinferens, linear, nominal, statik, kuat
DipengaruhiAlef,[2] C#,[2] C++,[2] Cyclone,[2][3] Erlang,[2] Haskell,[2] Limbo,[2] Newsqueak,[2] OCaml,[2] Ruby,[2] Scheme,[2] Standard ML,[2] Swift[2][4]
MempengaruhiCrystal, Elm,[5] Idris,[6] Spark,[7] Swift[8]
PelantarARM, IA-32, x86-64, MIPS, PowerPC, SPARC, RISC-V[9][10]
OSLinux, macOS, Windows, FreeBSD, OpenBSD,[11] Redox, Android, iOS[12]
LesenMIT atau Apache 2.0[13]
Sambugan fail biasa.rs, .rlib
Laman webwww.rust-lang.org

ContohSunting

Indahnya duniaSunting

fn main() {
    println!("Indahnya Dunia!");
}

Fungsi faktorialSunting

RekursifSunting

fn factorial(i: u64) -> u64 {
    match i {
        0 => 1,
        n => n * factorial(n-1)
    }
}

IteratifSunting

fn factorial(i: u64) -> u64 {
    let mut acc = 1;
    for num in 2..=i {
        acc *= num;
    }
    acc
}

RujukanSunting

  1. ^ The Rust Release Team (7 November 2019). "Announcing Rust 1.39.0". The Rust Programming Language Blog. Dicapai 7 November 2019. 
  2. ^ a b c d e f g h i j k l m "The Rust Reference: Appendix: Influences". Dicapai November 11, 2018. Rust is not a particularly original language, with design elements coming from a wide range of sources. Some of these are listed below (including elements that have since been removed): SML, OCaml [...] C++ [...] ML Kit, Cyclone [...] Haskell [...] Newsqueak, Alef, Limbo [...] Erlang [...] Ruby [...] Swift [...] Scheme [...] C# [...] 
  3. ^ "Note Research: Type System". 2015-02-01. Dicapai 2015-03-25. Papers that have had more or less influence on Rust, or which one might want to consult for inspiration or to understand Rust's background. [...] Region based memory management in Cyclone [...] Safe memory management in Cyclone 
  4. ^ "RFC for 'if let' expression". Dicapai December 4, 2014. 
  5. ^ "Command Optimizations?". 2014-06-26. Dicapai 2014-12-10. I just added the outline of a Result library that lets you use richer error messages. It's like Either except the names are more helpful. The names are inspired by Rust's Result library. 
  6. ^ "Idris – Uniqueness Types". Dicapai 2018-11-20. 
  7. ^ Jaloyan, Georges-Axel (19 October 2017). "Safe Pointers in SPARK 2014". Dicapai 1 January 2019. 
  8. ^ Lattner, Chris. "Chris Lattner's Homepage". Nondot.org. Dicapai 2019-05-14. 
  9. ^ "Rust Platform Support". Rust Forge. Dicapai 2019-05-19. 
  10. ^ "Frequently Asked Questions". Rust Embedded. Dicapai 2019-05-14. 
  11. ^ "OpenBSD ports". Dicapai 2018-04-03. 
  12. ^ "Building and Deploying a Rust library on iOS". 6 September 2017. Dicapai 11 January 2019. 

Pautan luarSunting