Much renaming and refreshing of RBE
This commit is contained in:
parent
dc8045a20e
commit
7f4f627769
15
rustbyexample/.gitignore
vendored
15
rustbyexample/.gitignore
vendored
@ -1,11 +1,6 @@
|
|||||||
/custom_types/*
|
/*.d/*
|
||||||
/hello/*
|
hello
|
||||||
/primitives/*
|
primitives
|
||||||
/variable_bindings/*
|
variable_bindings
|
||||||
/types/*
|
|
||||||
|
|
||||||
!/custom_types/*.rs
|
!/*.d/*.rs
|
||||||
!/hello/*.rs
|
|
||||||
!/primitives/*.rs
|
|
||||||
!/variable_bindings/*.rs
|
|
||||||
!/types/*.rs
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Person {
|
struct Person {
|
||||||
name: String,
|
name: String,
|
@ -22,5 +22,14 @@ fn main() {
|
|||||||
println!("borrow a section of the array as a slice");
|
println!("borrow a section of the array as a slice");
|
||||||
analyze_slice(&ys[1..4]);
|
analyze_slice(&ys[1..4]);
|
||||||
|
|
||||||
// println!("{}", xs[5]);
|
let empty_array: [u32; 0] = [];
|
||||||
|
assert_eq!(&empty_array, &[]);
|
||||||
|
assert_eq!(&empty_array, &[][..]);
|
||||||
|
|
||||||
|
for i in 0..xs.len() + 1 {
|
||||||
|
match xs.get(i) {
|
||||||
|
Some(xval) => println!("{}: {}", i, xval),
|
||||||
|
None => println!("Slow down! {} is too far!", i),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,6 +3,8 @@ fn main() {
|
|||||||
|
|
||||||
println!("1 - 2 = {}", 1i32 - 2);
|
println!("1 - 2 = {}", 1i32 - 2);
|
||||||
|
|
||||||
|
println!("1e4 is {}, -2.5e-3 is {}", 1e4, -2.5e-3);
|
||||||
|
|
||||||
println!("true AND false is {}", true && false);
|
println!("true AND false is {}", true && false);
|
||||||
println!("true OR false is {}", true || false);
|
println!("true OR false is {}", true || false);
|
||||||
println!("NOT true is {}", !true);
|
println!("NOT true is {}", !true);
|
@ -1,3 +1,5 @@
|
|||||||
|
#[allow(unused_variables)]
|
||||||
|
#[allow(unused_assignments)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let logical: bool = true;
|
let logical: bool = true;
|
||||||
|
|
15
rustbyexample/types.d/alias.rs
Normal file
15
rustbyexample/types.d/alias.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
type NanoSecond = u64;
|
||||||
|
type Inch = u64;
|
||||||
|
type U64 = u64;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let nanoseconds: NanoSecond = 5 as U64;
|
||||||
|
let inches: Inch = 2 as U64;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"{} nanoseconds + {} inches = {} unit?",
|
||||||
|
nanoseconds,
|
||||||
|
inches,
|
||||||
|
nanoseconds + inches
|
||||||
|
);
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
type NanoSecond = u64;
|
|
||||||
type Inch = u64;
|
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
type u64_t = u64;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let nanoseconds: NanoSecond = 5 as u64_t;
|
|
||||||
let inches: Inch = 2 as u64_t;
|
|
||||||
|
|
||||||
println!("{} nanoseconds + {} inches = {} unit?",
|
|
||||||
nanoseconds,
|
|
||||||
inches,
|
|
||||||
nanoseconds + inches);
|
|
||||||
}
|
|
@ -13,4 +13,3 @@ fn main() {
|
|||||||
let shadowed_binding = 2;
|
let shadowed_binding = 2;
|
||||||
println!("shadowed in outer block: {}", shadowed_binding);
|
println!("shadowed in outer block: {}", shadowed_binding);
|
||||||
}
|
}
|
||||||
|
|
@ -11,5 +11,5 @@ fn main() {
|
|||||||
|
|
||||||
let _unused_variable = 3u32;
|
let _unused_variable = 3u32;
|
||||||
|
|
||||||
let noisy_unused_variable = 2u32;
|
let _noisy_unused_variable = 2u32;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user