From 7f4f62776951d73e524127ba68de683c50af1a46 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 24 Sep 2023 20:46:41 -0400 Subject: [PATCH] Much renaming and refreshing of RBE --- rustbyexample/.gitignore | 15 +++++---------- .../constants.rs} | 0 .../enum.d/c_like.rs} | 0 .../enum.d/enum_use.rs} | 0 .../enum.d/testcase_linked_list.rs} | 0 .../enum.rs} | 0 .../structs.rs} | 1 + .../print_fmt.rs => hello.d/print.d/fmt.rs} | 0 .../{hello => hello.d/print.d}/print_debug.rs | 0 .../{hello => hello.d/print.d}/print_debug2.rs | 0 .../print.d/print_display.d}/testcase_list.rs | 0 .../{hello => hello.d/print.d}/print_display.rs | 0 .../{hello => hello.d/print.d}/print_display2.rs | 0 rustbyexample/{hello => hello.d}/print.rs | 0 rustbyexample/{hello => }/hello.rs | 0 .../primitives_array.rs => primitives.d/array.rs} | 11 ++++++++++- .../literals.rs} | 2 ++ .../tuples.rs} | 0 rustbyexample/{primitives => }/primitives.rs | 2 ++ rustbyexample/types.d/alias.rs | 15 +++++++++++++++ rustbyexample/{types => types.d}/cast.rs | 0 rustbyexample/{types => types.d}/inference.rs | 0 rustbyexample/{types => types.d}/literals.rs | 0 rustbyexample/types/alias.rs | 15 --------------- .../declare.rs | 0 .../freeze.rs | 0 .../mut.rs | 0 .../scope.rs | 0 .../scope2.rs | 1 - .../{variable_bindings => }/variable_bindings.rs | 2 +- 30 files changed, 36 insertions(+), 28 deletions(-) rename rustbyexample/{custom_types/custom_types_constants.rs => custom_types.d/constants.rs} (100%) rename rustbyexample/{custom_types/custom_types_enum_c_like.rs => custom_types.d/enum.d/c_like.rs} (100%) rename rustbyexample/{custom_types/custom_types_enum_use.rs => custom_types.d/enum.d/enum_use.rs} (100%) rename rustbyexample/{custom_types/custom_types_enum_testcase_linked_list.rs => custom_types.d/enum.d/testcase_linked_list.rs} (100%) rename rustbyexample/{custom_types/custom_types_enum.rs => custom_types.d/enum.rs} (100%) rename rustbyexample/{custom_types/custom_types_structs.rs => custom_types.d/structs.rs} (98%) rename rustbyexample/{hello/print_fmt.rs => hello.d/print.d/fmt.rs} (100%) rename rustbyexample/{hello => hello.d/print.d}/print_debug.rs (100%) rename rustbyexample/{hello => hello.d/print.d}/print_debug2.rs (100%) rename rustbyexample/{hello => hello.d/print.d/print_display.d}/testcase_list.rs (100%) rename rustbyexample/{hello => hello.d/print.d}/print_display.rs (100%) rename rustbyexample/{hello => hello.d/print.d}/print_display2.rs (100%) rename rustbyexample/{hello => hello.d}/print.rs (100%) rename rustbyexample/{hello => }/hello.rs (100%) rename rustbyexample/{primitives/primitives_array.rs => primitives.d/array.rs} (68%) rename rustbyexample/{primitives/primitives_literals.rs => primitives.d/literals.rs} (90%) rename rustbyexample/{primitives/primitives_tuples.rs => primitives.d/tuples.rs} (100%) rename rustbyexample/{primitives => }/primitives.rs (85%) create mode 100644 rustbyexample/types.d/alias.rs rename rustbyexample/{types => types.d}/cast.rs (100%) rename rustbyexample/{types => types.d}/inference.rs (100%) rename rustbyexample/{types => types.d}/literals.rs (100%) delete mode 100644 rustbyexample/types/alias.rs rename rustbyexample/{variable_bindings => variable_bindings.d}/declare.rs (100%) rename rustbyexample/{variable_bindings => variable_bindings.d}/freeze.rs (100%) rename rustbyexample/{variable_bindings => variable_bindings.d}/mut.rs (100%) rename rustbyexample/{variable_bindings => variable_bindings.d}/scope.rs (100%) rename rustbyexample/{variable_bindings => variable_bindings.d}/scope2.rs (99%) rename rustbyexample/{variable_bindings => }/variable_bindings.rs (88%) diff --git a/rustbyexample/.gitignore b/rustbyexample/.gitignore index 9ee95d2..d591051 100644 --- a/rustbyexample/.gitignore +++ b/rustbyexample/.gitignore @@ -1,11 +1,6 @@ -/custom_types/* -/hello/* -/primitives/* -/variable_bindings/* -/types/* +/*.d/* +hello +primitives +variable_bindings -!/custom_types/*.rs -!/hello/*.rs -!/primitives/*.rs -!/variable_bindings/*.rs -!/types/*.rs +!/*.d/*.rs diff --git a/rustbyexample/custom_types/custom_types_constants.rs b/rustbyexample/custom_types.d/constants.rs similarity index 100% rename from rustbyexample/custom_types/custom_types_constants.rs rename to rustbyexample/custom_types.d/constants.rs diff --git a/rustbyexample/custom_types/custom_types_enum_c_like.rs b/rustbyexample/custom_types.d/enum.d/c_like.rs similarity index 100% rename from rustbyexample/custom_types/custom_types_enum_c_like.rs rename to rustbyexample/custom_types.d/enum.d/c_like.rs diff --git a/rustbyexample/custom_types/custom_types_enum_use.rs b/rustbyexample/custom_types.d/enum.d/enum_use.rs similarity index 100% rename from rustbyexample/custom_types/custom_types_enum_use.rs rename to rustbyexample/custom_types.d/enum.d/enum_use.rs diff --git a/rustbyexample/custom_types/custom_types_enum_testcase_linked_list.rs b/rustbyexample/custom_types.d/enum.d/testcase_linked_list.rs similarity index 100% rename from rustbyexample/custom_types/custom_types_enum_testcase_linked_list.rs rename to rustbyexample/custom_types.d/enum.d/testcase_linked_list.rs diff --git a/rustbyexample/custom_types/custom_types_enum.rs b/rustbyexample/custom_types.d/enum.rs similarity index 100% rename from rustbyexample/custom_types/custom_types_enum.rs rename to rustbyexample/custom_types.d/enum.rs diff --git a/rustbyexample/custom_types/custom_types_structs.rs b/rustbyexample/custom_types.d/structs.rs similarity index 98% rename from rustbyexample/custom_types/custom_types_structs.rs rename to rustbyexample/custom_types.d/structs.rs index 090ff00..3d1f191 100644 --- a/rustbyexample/custom_types/custom_types_structs.rs +++ b/rustbyexample/custom_types.d/structs.rs @@ -1,3 +1,4 @@ +#[allow(dead_code)] #[derive(Debug)] struct Person { name: String, diff --git a/rustbyexample/hello/print_fmt.rs b/rustbyexample/hello.d/print.d/fmt.rs similarity index 100% rename from rustbyexample/hello/print_fmt.rs rename to rustbyexample/hello.d/print.d/fmt.rs diff --git a/rustbyexample/hello/print_debug.rs b/rustbyexample/hello.d/print.d/print_debug.rs similarity index 100% rename from rustbyexample/hello/print_debug.rs rename to rustbyexample/hello.d/print.d/print_debug.rs diff --git a/rustbyexample/hello/print_debug2.rs b/rustbyexample/hello.d/print.d/print_debug2.rs similarity index 100% rename from rustbyexample/hello/print_debug2.rs rename to rustbyexample/hello.d/print.d/print_debug2.rs diff --git a/rustbyexample/hello/testcase_list.rs b/rustbyexample/hello.d/print.d/print_display.d/testcase_list.rs similarity index 100% rename from rustbyexample/hello/testcase_list.rs rename to rustbyexample/hello.d/print.d/print_display.d/testcase_list.rs diff --git a/rustbyexample/hello/print_display.rs b/rustbyexample/hello.d/print.d/print_display.rs similarity index 100% rename from rustbyexample/hello/print_display.rs rename to rustbyexample/hello.d/print.d/print_display.rs diff --git a/rustbyexample/hello/print_display2.rs b/rustbyexample/hello.d/print.d/print_display2.rs similarity index 100% rename from rustbyexample/hello/print_display2.rs rename to rustbyexample/hello.d/print.d/print_display2.rs diff --git a/rustbyexample/hello/print.rs b/rustbyexample/hello.d/print.rs similarity index 100% rename from rustbyexample/hello/print.rs rename to rustbyexample/hello.d/print.rs diff --git a/rustbyexample/hello/hello.rs b/rustbyexample/hello.rs similarity index 100% rename from rustbyexample/hello/hello.rs rename to rustbyexample/hello.rs diff --git a/rustbyexample/primitives/primitives_array.rs b/rustbyexample/primitives.d/array.rs similarity index 68% rename from rustbyexample/primitives/primitives_array.rs rename to rustbyexample/primitives.d/array.rs index 95b3f55..df09770 100644 --- a/rustbyexample/primitives/primitives_array.rs +++ b/rustbyexample/primitives.d/array.rs @@ -22,5 +22,14 @@ fn main() { println!("borrow a section of the array as a slice"); 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), + } + } } diff --git a/rustbyexample/primitives/primitives_literals.rs b/rustbyexample/primitives.d/literals.rs similarity index 90% rename from rustbyexample/primitives/primitives_literals.rs rename to rustbyexample/primitives.d/literals.rs index de82f23..a1163ea 100644 --- a/rustbyexample/primitives/primitives_literals.rs +++ b/rustbyexample/primitives.d/literals.rs @@ -3,6 +3,8 @@ fn main() { 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 OR false is {}", true || false); println!("NOT true is {}", !true); diff --git a/rustbyexample/primitives/primitives_tuples.rs b/rustbyexample/primitives.d/tuples.rs similarity index 100% rename from rustbyexample/primitives/primitives_tuples.rs rename to rustbyexample/primitives.d/tuples.rs diff --git a/rustbyexample/primitives/primitives.rs b/rustbyexample/primitives.rs similarity index 85% rename from rustbyexample/primitives/primitives.rs rename to rustbyexample/primitives.rs index 34fa932..4973b02 100644 --- a/rustbyexample/primitives/primitives.rs +++ b/rustbyexample/primitives.rs @@ -1,3 +1,5 @@ +#[allow(unused_variables)] +#[allow(unused_assignments)] fn main() { let logical: bool = true; diff --git a/rustbyexample/types.d/alias.rs b/rustbyexample/types.d/alias.rs new file mode 100644 index 0000000..ae05067 --- /dev/null +++ b/rustbyexample/types.d/alias.rs @@ -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 + ); +} diff --git a/rustbyexample/types/cast.rs b/rustbyexample/types.d/cast.rs similarity index 100% rename from rustbyexample/types/cast.rs rename to rustbyexample/types.d/cast.rs diff --git a/rustbyexample/types/inference.rs b/rustbyexample/types.d/inference.rs similarity index 100% rename from rustbyexample/types/inference.rs rename to rustbyexample/types.d/inference.rs diff --git a/rustbyexample/types/literals.rs b/rustbyexample/types.d/literals.rs similarity index 100% rename from rustbyexample/types/literals.rs rename to rustbyexample/types.d/literals.rs diff --git a/rustbyexample/types/alias.rs b/rustbyexample/types/alias.rs deleted file mode 100644 index 062c650..0000000 --- a/rustbyexample/types/alias.rs +++ /dev/null @@ -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); -} diff --git a/rustbyexample/variable_bindings/declare.rs b/rustbyexample/variable_bindings.d/declare.rs similarity index 100% rename from rustbyexample/variable_bindings/declare.rs rename to rustbyexample/variable_bindings.d/declare.rs diff --git a/rustbyexample/variable_bindings/freeze.rs b/rustbyexample/variable_bindings.d/freeze.rs similarity index 100% rename from rustbyexample/variable_bindings/freeze.rs rename to rustbyexample/variable_bindings.d/freeze.rs diff --git a/rustbyexample/variable_bindings/mut.rs b/rustbyexample/variable_bindings.d/mut.rs similarity index 100% rename from rustbyexample/variable_bindings/mut.rs rename to rustbyexample/variable_bindings.d/mut.rs diff --git a/rustbyexample/variable_bindings/scope.rs b/rustbyexample/variable_bindings.d/scope.rs similarity index 100% rename from rustbyexample/variable_bindings/scope.rs rename to rustbyexample/variable_bindings.d/scope.rs diff --git a/rustbyexample/variable_bindings/scope2.rs b/rustbyexample/variable_bindings.d/scope2.rs similarity index 99% rename from rustbyexample/variable_bindings/scope2.rs rename to rustbyexample/variable_bindings.d/scope2.rs index b0cc34d..1604685 100644 --- a/rustbyexample/variable_bindings/scope2.rs +++ b/rustbyexample/variable_bindings.d/scope2.rs @@ -13,4 +13,3 @@ fn main() { let shadowed_binding = 2; println!("shadowed in outer block: {}", shadowed_binding); } - diff --git a/rustbyexample/variable_bindings/variable_bindings.rs b/rustbyexample/variable_bindings.rs similarity index 88% rename from rustbyexample/variable_bindings/variable_bindings.rs rename to rustbyexample/variable_bindings.rs index 6cdcadd..6f39fed 100644 --- a/rustbyexample/variable_bindings/variable_bindings.rs +++ b/rustbyexample/variable_bindings.rs @@ -11,5 +11,5 @@ fn main() { let _unused_variable = 3u32; - let noisy_unused_variable = 2u32; + let _noisy_unused_variable = 2u32; }