Rust (bahasa pengaturcaraan)
Penampilan
Muncul pada | 7 Julai 2010 |
---|---|
Direka oleh | Graydon Hoare |
Pembangun | The Rust Project |
Lepasan stabil | 1.39.0[1] (7 November 2019 ) |
Disiplin penjenisan | Diinferens, linear, nominal, statik, kuat |
Dipengaruhi | Alef,[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] |
Mempengaruhi | Crystal, Elm,[5] Idris,[6] Spark,[7] Swift[8] |
Pelantar | ARM, IA-32, x86-64, MIPS, PowerPC, SPARC, RISC-V[9][10] |
OS | Linux, macOS, Windows, FreeBSD, OpenBSD,[11] Redox, Android, iOS[12] |
Lesen | MIT atau Apache 2.0[13] |
Sambugan fail biasa | .rs, .rlib |
Laman web | www |
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).
Contoh
[sunting | sunting sumber]Indahnya dunia
[sunting | sunting sumber]fn main() {
println!("Indahnya Dunia!");
}
Fungsi faktorial
[sunting | sunting sumber]Rekursif
[sunting | sunting sumber]fn factorial(i: u64) -> u64 {
match i {
0 => 1,
n => n * factorial(n-1)
}
}
Iteratif
[sunting | sunting sumber]fn factorial(i: u64) -> u64 {
let mut acc = 1;
for num in 2..=i {
acc *= num;
}
acc
}
Rujukan
[sunting | sunting sumber]- ^ The Rust Release Team (7 November 2019). "Announcing Rust 1.39.0". The Rust Programming Language Blog. Dicapai pada 7 November 2019.
- ^ a b c d e f g h i j k l m "The Rust Reference: Appendix: Influences". Dicapai pada 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# [...]
- ^ "Note Research: Type System". 2015-02-01. Dicapai pada 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
- ^ "RFC for 'if let' expression". Dicapai pada December 4, 2014.
- ^ "Command Optimizations?". 2014-06-26. Dicapai pada 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.
- ^ "Idris – Uniqueness Types". Dicapai pada 2018-11-20.
- ^ Jaloyan, Georges-Axel (19 October 2017). "Safe Pointers in SPARK 2014". Dicapai pada 1 January 2019. Cite journal requires
|journal=
(bantuan) - ^ Lattner, Chris. "Chris Lattner's Homepage". Nondot.org. Dicapai pada 2019-05-14.
- ^ "Rust Platform Support". Rust Forge. Dicapai pada 2019-05-19.
- ^ "Frequently Asked Questions". Rust Embedded. Dicapai pada 2019-05-14.
- ^ "OpenBSD ports". Dicapai pada 2018-04-03.
- ^ "Building and Deploying a Rust library on iOS". 6 September 2017. Dicapai pada 11 January 2019.
- ^ "Rust Legal Policies". Rust-lang.org. Dicapai pada 2018-04-03.