Basic (com números e estruturado), dBase III Plus, Clipper, Pascal, Cobol, Delphi (ObjectPascal), C, C++, ActionScript (Flash), PHP, JavaScript, Python, Objective-C, Clojure, Java, Scala, Rust.
(Lisp, Haskell, Ruby)
fn main() {
println!("Hello, world!");
}
Tempo para gerar esse código:
cargo init
"Cargo is the Rust package manager"
"Cargo downloads your Rust package’s dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community’s package registry."
fn main() {
let a: u8 = 2;
println!("{}", a);
}
fn main() {
let a = 2u8;
println!("{}", a);
}
fn main() {
let a = 2;
println!("{}", a);
}
fn factorial(i: u64) -> u64 {
match i {
0 => 1,
n => n * factorial(n-1)
}
}
fn is_pred(i: u64) -> Bool {
if i % 2 == 0 {
True
} else {
False
}
}
fn is_pred(i: u64) -> Bool {
i % 2 == 0
}
enum IPAddr {
IPV4,
IPV6
}
enum IPAddr {
IPV4(String),
IPV6(String)
}
let home = IpAddr::IPV4(String::from("127.0.0.1");
match home {
IPV4(ipv4_address) => println!("IPv4 addr: {}", ipv4_address),
IPV6(ipv6_address) => println!("Ipv6 addr: {}", ipv6_address),
}
struct MyStruct {
a_field: String,
r_a: [2u64; 10],
}
impl MyStruct {
fn first_element(&self) -> u64 {
self.r_a.get(0)
}
}
trait Summarize {
fn summarize(&self) -> String;
}
impl Summarize for MyStruct {
fn summarize(&self) -> String {
self.a_field
}
}
fn make_summary<T>(summarizable: T) {
T.summarize()
}
fn make_summary<T>(summarizable: T)
where T: Summarize
{
T.summarize()
}
fn may_not_exist(value: Option<String>) {
match value {
Some(the_string) => println!("I got a string! {}", the_string),
None => println!("I got nothing")
}
}
fn main() {
let a = String::from("A reference to a string in the code section copied to the stack");
let b = a;
println!("The string is: {}", a);
}
fn main() {
let a = String::from("A reference to a string in the code section copied to the stack");
let b = &a;
println!("The string is: {}", a);
}
presente := Presente { ... }
canal <- presente
presente := Presente { ... }
canal <- presente
presente.abrir()
fn main() {
let a = 3;
a = 5;
}
enum Result<T, E> {
Ok(T),
Err(E),
}
match File::create("something.txt") {
Ok(fp) => fp.write_all(b"Hello world"),
Err(err) => println!("Failure! {}", err),
}
fn main() {
let a = 2;
a = 3;
println!("{}", a);
}
3 | let a = 2;
| -
| |
| first assignment to `a`
| help: make this binding mutable: `mut a`
4 | a = 3;
| ^^^^^ cannot assign twice to immutable variable
3 | let a = 2;
| -
| |
| first assignment to `a`
| help: make this binding mutable: `mut a`
4 | a = 3;
| ^^^^^ cannot assign twice to immutable variable
3 | let a = 2;
| -
| |
| first assignment to `a`
| help: make this binding mutable: `mut a`
4 | a = 3;
| ^^^^^ cannot assign twice to immutable variable
A linguagem mais amada segundo o StackOverflow Survey 2019
... pelo 4⁰ ano seguido.