Added more examples for Rust
This commit is contained in:
parent
b7a448ce36
commit
14784cd6a1
12
src/main.rs
12
src/main.rs
|
@ -1,9 +1,17 @@
|
||||||
//mod print;
|
//mod print;
|
||||||
//mod vars;
|
//mod vars;
|
||||||
mod types;
|
//mod types;
|
||||||
|
//mod strings;
|
||||||
|
//mod tuples;
|
||||||
|
//mod arrays;
|
||||||
|
mod vectors;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
//print::run();
|
//print::run();
|
||||||
//vars::run();
|
//vars::run();
|
||||||
types::run();
|
//types::run();
|
||||||
|
//strings::run();
|
||||||
|
//tuples::run();
|
||||||
|
//arrays::run();
|
||||||
|
vectors::run();
|
||||||
}
|
}
|
||||||
|
|
26
src/types.rs
26
src/types.rs
|
@ -1 +1,25 @@
|
||||||
pub fn run() {}
|
pub fn run() {
|
||||||
|
// will be by default i32
|
||||||
|
let x = 1;
|
||||||
|
|
||||||
|
// will be inferred as f32
|
||||||
|
let y = 2.5;
|
||||||
|
|
||||||
|
// add explicit type
|
||||||
|
let z: i64 = 453453;
|
||||||
|
|
||||||
|
// find max size
|
||||||
|
println!("Max i32: {}", std::i32::MAX);
|
||||||
|
println!("Max i64: {}", std::i64::MAX);
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
let is_active = true;
|
||||||
|
|
||||||
|
// get boolean from . expression
|
||||||
|
let is_greater: bool = 10 < 5;
|
||||||
|
|
||||||
|
// Char
|
||||||
|
let a1 = '\u{1F600}';
|
||||||
|
|
||||||
|
println!("{:?}",(x,y,z,is_active, is_greater,a1));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue