From 7d92f735c93a2ea721c4a5f720b6d4f6b673a697 Mon Sep 17 00:00:00 2001 From: Luke Tidd Date: Wed, 25 Jun 2025 00:30:17 +0000 Subject: [PATCH] starting over --- array_access/Cargo.toml | 8 - array_access/src/main.rs | 18 -- branches/Cargo.toml | 8 - branches/src/main.rs | 20 --- ch03_practice/Cargo.toml | 8 - ch03_practice/src/main.rs | 40 ----- comments/Cargo.toml | 8 - comments/src/main.rs | 8 - exercism/exercism_notes | 11 -- .../rust/assembly-line/.exercism/config.json | 19 --- .../assembly-line/.exercism/metadata.json | 1 - exercism/rust/assembly-line/.gitignore | 8 - exercism/rust/assembly-line/Cargo.toml | 4 - exercism/rust/assembly-line/HELP.md | 85 ---------- exercism/rust/assembly-line/HINTS.md | 12 -- exercism/rust/assembly-line/README.md | 88 ---------- exercism/rust/assembly-line/src/lib.rs | 19 --- .../rust/assembly-line/tests/assembly-line.rs | 62 ------- .../rust/hello-world/.exercism/config.json | 42 ----- .../rust/hello-world/.exercism/metadata.json | 1 - exercism/rust/hello-world/.gitignore | 8 - exercism/rust/hello-world/Cargo.toml | 4 - exercism/rust/hello-world/GETTING_STARTED.md | 92 ---------- exercism/rust/hello-world/HELP.md | 85 ---------- exercism/rust/hello-world/README.md | 53 ------ exercism/rust/hello-world/src/lib.rs | 4 - .../rust/hello-world/tests/hello-world.rs | 4 - .../.exercism/config.json | 20 --- .../.exercism/metadata.json | 1 - .../rust/lucians-luscious-lasagna/.gitignore | 8 - .../rust/lucians-luscious-lasagna/Cargo.toml | 4 - .../rust/lucians-luscious-lasagna/HELP.md | 85 ---------- .../rust/lucians-luscious-lasagna/HINTS.md | 31 ---- .../rust/lucians-luscious-lasagna/README.md | 159 ------------------ .../rust/lucians-luscious-lasagna/src/lib.rs | 18 -- .../tests/lucians-luscious-lasagna.rs | 34 ---- .../.exercism/config.json | 18 -- .../.exercism/metadata.json | 1 - exercism/rust/semi-structured-logs/.gitignore | 8 - exercism/rust/semi-structured-logs/Cargo.toml | 9 - exercism/rust/semi-structured-logs/HELP.md | 85 ---------- exercism/rust/semi-structured-logs/HINTS.md | 13 -- exercism/rust/semi-structured-logs/README.md | 64 ------- exercism/rust/semi-structured-logs/src/lib.rs | 32 ---- .../tests/semi-structured-logs.rs | 53 ------ guessing_game/Cargo.toml | 9 - guessing_game/src/main.rs | 58 ------- hello_cargo/.gitignore | 2 - hello_cargo/Cargo.toml | 8 - hello_cargo/src/main.rs | 3 - ownership/Cargo.toml | 8 - ownership/src/main.rs | 43 ----- plants | 24 --- rust_book/02/guessing_game | 1 + slice/Cargo.toml | 8 - slice/src/main.rs | 29 ---- tuple1/Cargo.toml | 8 - tuple1/src/main.rs | 6 - 58 files changed, 1 insertion(+), 1569 deletions(-) delete mode 100644 array_access/Cargo.toml delete mode 100644 array_access/src/main.rs delete mode 100644 branches/Cargo.toml delete mode 100644 branches/src/main.rs delete mode 100644 ch03_practice/Cargo.toml delete mode 100644 ch03_practice/src/main.rs delete mode 100644 comments/Cargo.toml delete mode 100644 comments/src/main.rs delete mode 100755 exercism/exercism_notes delete mode 100644 exercism/rust/assembly-line/.exercism/config.json delete mode 100644 exercism/rust/assembly-line/.exercism/metadata.json delete mode 100644 exercism/rust/assembly-line/.gitignore delete mode 100644 exercism/rust/assembly-line/Cargo.toml delete mode 100644 exercism/rust/assembly-line/HELP.md delete mode 100644 exercism/rust/assembly-line/HINTS.md delete mode 100644 exercism/rust/assembly-line/README.md delete mode 100644 exercism/rust/assembly-line/src/lib.rs delete mode 100644 exercism/rust/assembly-line/tests/assembly-line.rs delete mode 100644 exercism/rust/hello-world/.exercism/config.json delete mode 100644 exercism/rust/hello-world/.exercism/metadata.json delete mode 100644 exercism/rust/hello-world/.gitignore delete mode 100644 exercism/rust/hello-world/Cargo.toml delete mode 100644 exercism/rust/hello-world/GETTING_STARTED.md delete mode 100644 exercism/rust/hello-world/HELP.md delete mode 100644 exercism/rust/hello-world/README.md delete mode 100644 exercism/rust/hello-world/src/lib.rs delete mode 100644 exercism/rust/hello-world/tests/hello-world.rs delete mode 100644 exercism/rust/lucians-luscious-lasagna/.exercism/config.json delete mode 100644 exercism/rust/lucians-luscious-lasagna/.exercism/metadata.json delete mode 100644 exercism/rust/lucians-luscious-lasagna/.gitignore delete mode 100644 exercism/rust/lucians-luscious-lasagna/Cargo.toml delete mode 100644 exercism/rust/lucians-luscious-lasagna/HELP.md delete mode 100644 exercism/rust/lucians-luscious-lasagna/HINTS.md delete mode 100644 exercism/rust/lucians-luscious-lasagna/README.md delete mode 100644 exercism/rust/lucians-luscious-lasagna/src/lib.rs delete mode 100644 exercism/rust/lucians-luscious-lasagna/tests/lucians-luscious-lasagna.rs delete mode 100644 exercism/rust/semi-structured-logs/.exercism/config.json delete mode 100644 exercism/rust/semi-structured-logs/.exercism/metadata.json delete mode 100644 exercism/rust/semi-structured-logs/.gitignore delete mode 100644 exercism/rust/semi-structured-logs/Cargo.toml delete mode 100644 exercism/rust/semi-structured-logs/HELP.md delete mode 100644 exercism/rust/semi-structured-logs/HINTS.md delete mode 100644 exercism/rust/semi-structured-logs/README.md delete mode 100644 exercism/rust/semi-structured-logs/src/lib.rs delete mode 100644 exercism/rust/semi-structured-logs/tests/semi-structured-logs.rs delete mode 100644 guessing_game/Cargo.toml delete mode 100644 guessing_game/src/main.rs delete mode 100644 hello_cargo/.gitignore delete mode 100644 hello_cargo/Cargo.toml delete mode 100644 hello_cargo/src/main.rs delete mode 100644 ownership/Cargo.toml delete mode 100644 ownership/src/main.rs delete mode 100644 plants create mode 160000 rust_book/02/guessing_game delete mode 100644 slice/Cargo.toml delete mode 100644 slice/src/main.rs delete mode 100644 tuple1/Cargo.toml delete mode 100644 tuple1/src/main.rs diff --git a/array_access/Cargo.toml b/array_access/Cargo.toml deleted file mode 100644 index 5378f9b..0000000 --- a/array_access/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "array_access" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/array_access/src/main.rs b/array_access/src/main.rs deleted file mode 100644 index 0aa3f68..0000000 --- a/array_access/src/main.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::io; - -fn main() { - let a = [1, 2, 3, 4, 5]; - let mut index = String::new(); - io::stdin() - .read_line(&mut index) - .expect("doh"); - let index: usize = index - .trim() - .parse() - .expect("notta num"); - - let element = a[index]; - - println!("you gotta {element}"); - -} diff --git a/branches/Cargo.toml b/branches/Cargo.toml deleted file mode 100644 index 6934aa4..0000000 --- a/branches/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "branches" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/branches/src/main.rs b/branches/src/main.rs deleted file mode 100644 index b04db10..0000000 --- a/branches/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -fn main() { - let number = 3; - let b = if number < 5 { "duh" } else { "blwewew" }; - println!("{number} {b}"); - - let mut x = 0.0; - let mut y = 0.0; - let q = 'outer: loop { - x += 0.1; - loop { - y += 0.1; - if y > 2.0 { - break 'outer y - } - println!("x: {}, y: {}", x, y); - } - }; - println!("y: {q}"); - println!((1..4)) -} diff --git a/ch03_practice/Cargo.toml b/ch03_practice/Cargo.toml deleted file mode 100644 index 509298c..0000000 --- a/ch03_practice/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "ch03_practice" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/ch03_practice/src/main.rs b/ch03_practice/src/main.rs deleted file mode 100644 index 304475c..0000000 --- a/ch03_practice/src/main.rs +++ /dev/null @@ -1,40 +0,0 @@ -fn f_to_c(f: f64) -> f64 { - (f - 32.0) * (5.0 / 9.0) -} - -fn c_to_f(c: f64) -> f64 { - c * (9.0 / 5.0) + 32.0 -} - -fn main() { - - // f to c / c to f - let f1 = 0.0; - let f2 = 32.0; - let f3 = 80.0; - let f4 = 212.0; - let c1 = f_to_c(f1); - let c2 = f_to_c(f2); - let c3 = f_to_c(f3); - let c4 = f_to_c(f4); - - println!("{f1}f {c1}c"); - println!("{f2}f {c2}c"); - println!("{f3}f {c3}c"); - println!("{f4}f {c4}c"); - - let f5 = c_to_f(100.0); - println!("100c = {f5}f"); - // fib - // - let mut x1 = 0; - let mut x2 = 1; - let mut temp = 0; - while x1 < 2000 { - println!("x: {x1}"); - temp = x2; - x2 = x1 + x2; - x1 = temp; - } -} - diff --git a/comments/Cargo.toml b/comments/Cargo.toml deleted file mode 100644 index 476474d..0000000 --- a/comments/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "comments" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/comments/src/main.rs b/comments/src/main.rs deleted file mode 100644 index e10d362..0000000 --- a/comments/src/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - // this is a comment - /* is this a comment? - * - * looks like it - */ - println!("Hello, world!"); -} diff --git a/exercism/exercism_notes b/exercism/exercism_notes deleted file mode 100755 index 0fb25aa..0000000 --- a/exercism/exercism_notes +++ /dev/null @@ -1,11 +0,0 @@ -site: https://exercism.org/tracks/rust/exercises/ - -* download exercise: - exercism download --exercise= --track= - - example: exercism download --exercise=semi-structured-logs --track=rust - -* submit solution: - exercism submit - - example: exercism submit semi-structured-logs/src/lib.rs diff --git a/exercism/rust/assembly-line/.exercism/config.json b/exercism/rust/assembly-line/.exercism/config.json deleted file mode 100644 index a8a9750..0000000 --- a/exercism/rust/assembly-line/.exercism/config.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "authors": [ - "LewisClement", - "efx" - ], - "files": { - "solution": [ - "src/lib.rs", - "Cargo.toml" - ], - "test": [ - "tests/assembly-line.rs" - ], - "exemplar": [ - ".meta/exemplar.rs" - ] - }, - "blurb": "Learn about numbers while working on an assembly line for cars." -} diff --git a/exercism/rust/assembly-line/.exercism/metadata.json b/exercism/rust/assembly-line/.exercism/metadata.json deleted file mode 100644 index ec1a957..0000000 --- a/exercism/rust/assembly-line/.exercism/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"track":"rust","exercise":"assembly-line","id":"968486e893b74e46aa6a188c5aa5386a","url":"https://exercism.org/tracks/rust/exercises/assembly-line","handle":"habys","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/exercism/rust/assembly-line/.gitignore b/exercism/rust/assembly-line/.gitignore deleted file mode 100644 index db7f315..0000000 --- a/exercism/rust/assembly-line/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercism/rust/assembly-line/Cargo.toml b/exercism/rust/assembly-line/Cargo.toml deleted file mode 100644 index 5a7f2c4..0000000 --- a/exercism/rust/assembly-line/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "assembly-line" -version = "0.1.0" -edition = "2021" diff --git a/exercism/rust/assembly-line/HELP.md b/exercism/rust/assembly-line/HELP.md deleted file mode 100644 index 7857ff6..0000000 --- a/exercism/rust/assembly-line/HELP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Help - -## Running the tests - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run _only ignored_ tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -If you are using Rust 1.51 or later, you can run _all_ tests with - -```bash -$ cargo test -- --include-ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored, use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the online [test documentation][rust-tests]. - -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Submitting your solution - -You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. -This command will upload your solution to the Exercism website and print the solution page's URL. - -It's possible to submit an incomplete solution which allows you to: - -- See how others have completed the exercise -- Request help from a mentor - -## Need to get help? - -If you'd like help solving the exercise, check the following pages: - -- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) -- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) -- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) - -Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. - -## Rust Installation - -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! - -If you want to know more about Exercism, take a look at the [contribution guide]. - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. - -[help-page]: https://exercism.org/tracks/rust/learning -[github]: https://github.com/exercism/rust -[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/exercism/rust/assembly-line/HINTS.md b/exercism/rust/assembly-line/HINTS.md deleted file mode 100644 index 43fcd81..0000000 --- a/exercism/rust/assembly-line/HINTS.md +++ /dev/null @@ -1,12 +0,0 @@ -# Hints - -## General - -## 1. Calculate the production rate per hour - -- Determining the success rate can be done through a [conditional statement](https://doc.rust-lang.org/stable/book/ch03-05-control-flow.html#if-expressions) or with [pattern matching](https://doc.rust-lang.org/stable/book/ch18-01-all-the-places-for-patterns.html#match-arms). -- As Rust only allows multiplication between values of the same type, some [type casting](https://doc.rust-lang.org/rust-by-example/types/cast.html) will have to be done. - -## 2. Calculate the number of working items produced per minute - -- Just like multiplication, division is only possible between numbers of the same type. By writing a number with a decimal point (e.g. `1.0` instead of `1`) we can write inline constants with a floating point type. \ No newline at end of file diff --git a/exercism/rust/assembly-line/README.md b/exercism/rust/assembly-line/README.md deleted file mode 100644 index 15164a4..0000000 --- a/exercism/rust/assembly-line/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# Assembly Line - -Welcome to Assembly Line on Exercism's Rust Track. -If you need help running the tests or submitting your code, check out `HELP.md`. -If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) - -## Introduction - -## Numbers - -There are two different categories of numbers in Rust: integers (which can be signed or unsigned) and floating-point numbers. - -## Integers - -- Integers: numbers with no digits behind the decimal separator (whole numbers). - Integer types can either store only positive numbers (unsigned) or store either positive and negative numbers (signed). - Examples are -6, 0, 1, 25, 976 and 500000. - -## Floating-Point Numbers - -- Floating-point numbers: numbers with zero or more digits behind the decimal separator. - Examples are -2.4, 0.1, 3.14, 16.984025 and 1024.0. - -## Naming numeric types - -The name of a numeric type consists of two parts: - -- A letter to specify whether it's an unsigned integer (u), signed integer (i), or floating-point number (f). -- A number to specify the type's size in bits. Larger types have a greater range between minimum and maximum values. - For floating points it will also allow for more numbers behind the decimal separator. - -The following combinations are possible: - -- 8 bits: `u8`, `i8` -- 16 bits: `u16`, `i16` -- 32 bits: `u32`, `i32`, `f32` -- 64 bits: `u64`, `i64`, `f64` -- 128 bits: `u128`, `i128` - -Note that there are only 32-bits and 64-bits variants for floating-point numbers. - -## Converting between number types - -Rust doesn't do any implicit type conversion. -This means that if you need to turn one numeric type into another, you have to do so explicitly. -When converting from a larger type to a smaller one (for instance `u64` to `u32`) you could lose data. -Converting from a floating point to an integer **will** lose everything behind the decimal point, effectively rounding down. - -## Instructions - -In this exercise you'll be writing code to analyze the production of an assembly line in a car factory. The assembly line's speed can range from `0` (off) to `10` (maximum). - -At its lowest speed (`1`), `221` cars are produced each hour. The production increases linearly with the speed. So with the speed set to `4`, it should produce `4 * 221 = 884` cars per hour. However, higher speeds increase the likelihood that faulty cars are produced, which then have to be discarded. The following table shows how speed influences the success rate: - -- `1` to `4`: 100% success rate. -- `5` to `8`: 90% success rate. -- `9` and `10`: 77% success rate. - -You have two tasks. - -## 1. Calculate the production rate per hour - -Implement a method to calculate the assembly line's production rate per hour, taking into account its success rate: - -```rust -assembly_line::production_rate_per_hour(6) -// Returns: 1193.4 -``` - -Note that the value returned is an `f64`. - -## 2. Calculate the number of working items produced per minute - -Implement a method to calculate how many working cars are produced per minute: - -```rust -assembly_line::working_items_per_minute(6) -// Returns: 19 -``` - -Note that the value returned is an `u32`. - -## Source - -### Created by - -- @LewisClement -- @efx \ No newline at end of file diff --git a/exercism/rust/assembly-line/src/lib.rs b/exercism/rust/assembly-line/src/lib.rs deleted file mode 100644 index cd92655..0000000 --- a/exercism/rust/assembly-line/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This stub file contains items that aren't used yet; feel free to remove this module attribute -// to enable stricter warnings. -#![allow(unused)] - -pub fn production_rate_per_hour(speed: u8) -> f64 { - let mut success_rate = 0.0; - if speed >= 1 && speed <= 4 { - success_rate = 1.0 - } else if speed > 4 && speed <= 8 { - success_rate = 0.9 - } else if speed > 8 && speed <= 10 { - success_rate = 0.77 - } - speed as f64 * 221.0 * success_rate -} - -pub fn working_items_per_minute(speed: u8) -> u32 { - (production_rate_per_hour(speed) / 60.0) as u32 -} diff --git a/exercism/rust/assembly-line/tests/assembly-line.rs b/exercism/rust/assembly-line/tests/assembly-line.rs deleted file mode 100644 index 89b3e92..0000000 --- a/exercism/rust/assembly-line/tests/assembly-line.rs +++ /dev/null @@ -1,62 +0,0 @@ -fn process_rate_per_hour(speed: u8, expected_rate: f64) { - let actual_rate = assembly_line::production_rate_per_hour(speed); - let actual_rate = (actual_rate * 100.0).round() / 100.0; - assert!((actual_rate - expected_rate).abs() < f64::EPSILON); -} - -fn process_rate_per_minute(speed: u8, expected_rate: u32) { - assert_eq!( - assembly_line::working_items_per_minute(speed), - expected_rate - ); -} - -#[test] -fn production_rate_per_hour_at_speed_zero() { - process_rate_per_hour(0, 0.0); -} - -#[test] -fn production_rate_per_hour_at_speed_one() { - process_rate_per_hour(1, 221.0); -} - -#[test] -fn production_rate_per_hour_at_speed_four() { - process_rate_per_hour(4, 884.0); -} - -#[test] -fn production_rate_per_hour_at_speed_seven() { - process_rate_per_hour(7, 1392.3); -} - -#[test] -fn production_rate_per_hour_at_speed_nine() { - process_rate_per_hour(9, 1531.53); -} - -#[test] -fn production_rate_per_minute_at_speed_zero() { - process_rate_per_minute(0, 0); -} - -#[test] -fn production_rate_per_minute_at_speed_one() { - process_rate_per_minute(1, 3); -} - -#[test] -fn production_rate_per_minute_at_speed_five() { - process_rate_per_minute(5, 16); -} - -#[test] -fn production_rate_per_minute_at_speed_eight() { - process_rate_per_minute(8, 26); -} - -#[test] -fn production_rate_per_minute_at_speed_ten() { - process_rate_per_minute(10, 28); -} diff --git a/exercism/rust/hello-world/.exercism/config.json b/exercism/rust/hello-world/.exercism/config.json deleted file mode 100644 index 93473d3..0000000 --- a/exercism/rust/hello-world/.exercism/config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "authors": [ - "EduardoBautista" - ], - "contributors": [ - "ashleygwilliams", - "ClashTheBunny", - "coriolinus", - "cwhakes", - "dvoytik", - "EduardoBautista", - "efx", - "ErikSchierboom", - "hydhknn", - "IanWhitney", - "ijanos", - "kytrinyx", - "lutostag", - "nfiles", - "petertseng", - "regnerjr", - "rofrol", - "stringparser", - "xakon", - "ZapAnton" - ], - "files": { - "solution": [ - "src/lib.rs", - "Cargo.toml" - ], - "test": [ - "tests/hello-world.rs" - ], - "example": [ - ".meta/example.rs" - ] - }, - "blurb": "The classical introductory exercise. Just say \"Hello, World!\".", - "source": "This is an exercise to introduce users to using Exercism", - "source_url": "http://en.wikipedia.org/wiki/%22Hello,_world!%22_program" -} diff --git a/exercism/rust/hello-world/.exercism/metadata.json b/exercism/rust/hello-world/.exercism/metadata.json deleted file mode 100644 index c8db479..0000000 --- a/exercism/rust/hello-world/.exercism/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"track":"rust","exercise":"hello-world","id":"4cef4d23d1f048e6a330e39401237fcb","url":"https://exercism.org/tracks/rust/exercises/hello-world","handle":"habys","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/exercism/rust/hello-world/.gitignore b/exercism/rust/hello-world/.gitignore deleted file mode 100644 index db7f315..0000000 --- a/exercism/rust/hello-world/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercism/rust/hello-world/Cargo.toml b/exercism/rust/hello-world/Cargo.toml deleted file mode 100644 index face5df..0000000 --- a/exercism/rust/hello-world/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -edition = "2021" -name = "hello-world" -version = "1.1.0" diff --git a/exercism/rust/hello-world/GETTING_STARTED.md b/exercism/rust/hello-world/GETTING_STARTED.md deleted file mode 100644 index 164ec61..0000000 --- a/exercism/rust/hello-world/GETTING_STARTED.md +++ /dev/null @@ -1,92 +0,0 @@ -# Getting Started - -These exercises lean on Test-Driven Development (TDD), but they're not -an exact match. - -The following steps assume that you are in the same directory as the exercise. - -You must have Rust installed. -Follow the [Installation chapter in the Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html). -The [Rust language section](http://exercism.org/languages/rust) -section from exercism is also useful. - -## Step 1 - -Run the test suite. It can be run with `cargo`, which is installed with Rust. - -```sh -$ cargo test -``` - -This will compile the `hello-world` crate and run the test, which fails. - -```sh -running 1 test -test test_hello_world ... FAILED - -failures: - ----- test_hello_world stdout ---- -thread 'test_hello_world' panicked at 'assertion failed: `(left == right)` -(left: `"Hello, World!"`, right: `"Goodbye, Mars!"`)', tests/hello-world.rs:5 - -failures: - test_hello_world - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured -``` - -### Understanding Test Failures - -The `test_hello_world` failure states that it is expecting the value, -`"Hello, World!"`, to be returned from `hello()`. -The left side of the assertion (at line 5) should be equal to the right side. - -```sh ----- test_hello_world stdout ---- -thread 'test_hello_world' panicked at 'assertion failed: `(left == right)` -(left: `"Hello, World!"`, right: `"Goodbye, Mars!"`)', tests/hello-world.rs:5 -``` - -### Fixing the Error - -To fix it, open up `src/lib.rs` and change the `hello` function to return -`"Hello, World!"` instead of `"Goodbye, Mars!"`. - -```rust -pub fn hello() -> &'static str { - "Hello, World!" -} -``` - -## Step 2 - -Run the test again. This time, it will pass. - -```sh -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured - - Running target/debug/deps/hello_world-bd1f06dc726ef14f - -running 1 test -test test_hello_world ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured - - Doc-tests hello-world - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured -``` - -## Submit - -Once the test is passing, you can submit your code with the following -command: - -```sh -$ exercism submit src/lib.rs -``` diff --git a/exercism/rust/hello-world/HELP.md b/exercism/rust/hello-world/HELP.md deleted file mode 100644 index 7857ff6..0000000 --- a/exercism/rust/hello-world/HELP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Help - -## Running the tests - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run _only ignored_ tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -If you are using Rust 1.51 or later, you can run _all_ tests with - -```bash -$ cargo test -- --include-ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored, use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the online [test documentation][rust-tests]. - -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Submitting your solution - -You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. -This command will upload your solution to the Exercism website and print the solution page's URL. - -It's possible to submit an incomplete solution which allows you to: - -- See how others have completed the exercise -- Request help from a mentor - -## Need to get help? - -If you'd like help solving the exercise, check the following pages: - -- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) -- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) -- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) - -Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. - -## Rust Installation - -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! - -If you want to know more about Exercism, take a look at the [contribution guide]. - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. - -[help-page]: https://exercism.org/tracks/rust/learning -[github]: https://github.com/exercism/rust -[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/exercism/rust/hello-world/README.md b/exercism/rust/hello-world/README.md deleted file mode 100644 index 4ece0fa..0000000 --- a/exercism/rust/hello-world/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Hello World - -Welcome to Hello World on Exercism's Rust Track. -If you need help running the tests or submitting your code, check out `HELP.md`. - -## Instructions - -The classical introductory exercise. Just say "Hello, World!". - -["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is -the traditional first program for beginning programming in a new language -or environment. - -The objectives are simple: - -- Write a function that returns the string "Hello, World!". -- Run the test suite and make sure that it succeeds. -- Submit your solution and check it at the website. - -If everything goes well, you will be ready to fetch your first real exercise. - -## Source - -### Created by - -- @EduardoBautista - -### Contributed to by - -- @ashleygwilliams -- @ClashTheBunny -- @coriolinus -- @cwhakes -- @dvoytik -- @EduardoBautista -- @efx -- @ErikSchierboom -- @hydhknn -- @IanWhitney -- @ijanos -- @kytrinyx -- @lutostag -- @nfiles -- @petertseng -- @regnerjr -- @rofrol -- @stringparser -- @xakon -- @ZapAnton - -### Based on - -This is an exercise to introduce users to using Exercism - http://en.wikipedia.org/wiki/%22Hello,_world!%22_program \ No newline at end of file diff --git a/exercism/rust/hello-world/src/lib.rs b/exercism/rust/hello-world/src/lib.rs deleted file mode 100644 index 5c2db6d..0000000 --- a/exercism/rust/hello-world/src/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -// &'static is a "lifetime specifier", something you'll learn more about later -pub fn hello() -> &'static str { - "Hello, World!" -} diff --git a/exercism/rust/hello-world/tests/hello-world.rs b/exercism/rust/hello-world/tests/hello-world.rs deleted file mode 100644 index b29f953..0000000 --- a/exercism/rust/hello-world/tests/hello-world.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[test] -fn test_hello_world() { - assert_eq!("Hello, World!", hello_world::hello()); -} diff --git a/exercism/rust/lucians-luscious-lasagna/.exercism/config.json b/exercism/rust/lucians-luscious-lasagna/.exercism/config.json deleted file mode 100644 index 1a3417d..0000000 --- a/exercism/rust/lucians-luscious-lasagna/.exercism/config.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "authors": [ - "coriolinus", - "ErikSchierboom" - ], - "files": { - "solution": [ - "src/lib.rs", - "Cargo.toml" - ], - "test": [ - "tests/lucians-luscious-lasagna.rs" - ], - "exemplar": [ - ".meta/exemplar.rs" - ] - }, - "icon": "lasagna", - "blurb": "Learn about the basics of Rust by following a lasagna recipe." -} diff --git a/exercism/rust/lucians-luscious-lasagna/.exercism/metadata.json b/exercism/rust/lucians-luscious-lasagna/.exercism/metadata.json deleted file mode 100644 index 72c59eb..0000000 --- a/exercism/rust/lucians-luscious-lasagna/.exercism/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"track":"rust","exercise":"lucians-luscious-lasagna","id":"4a9c1735c39a4565b5c7cb5cb1d7a6cd","url":"https://exercism.org/tracks/rust/exercises/lucians-luscious-lasagna","handle":"habys","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/exercism/rust/lucians-luscious-lasagna/.gitignore b/exercism/rust/lucians-luscious-lasagna/.gitignore deleted file mode 100644 index db7f315..0000000 --- a/exercism/rust/lucians-luscious-lasagna/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercism/rust/lucians-luscious-lasagna/Cargo.toml b/exercism/rust/lucians-luscious-lasagna/Cargo.toml deleted file mode 100644 index 6f88766..0000000 --- a/exercism/rust/lucians-luscious-lasagna/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "lucians-luscious-lasagna" -version = "0.1.0" -edition = "2021" diff --git a/exercism/rust/lucians-luscious-lasagna/HELP.md b/exercism/rust/lucians-luscious-lasagna/HELP.md deleted file mode 100644 index 7857ff6..0000000 --- a/exercism/rust/lucians-luscious-lasagna/HELP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Help - -## Running the tests - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run _only ignored_ tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -If you are using Rust 1.51 or later, you can run _all_ tests with - -```bash -$ cargo test -- --include-ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored, use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the online [test documentation][rust-tests]. - -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Submitting your solution - -You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. -This command will upload your solution to the Exercism website and print the solution page's URL. - -It's possible to submit an incomplete solution which allows you to: - -- See how others have completed the exercise -- Request help from a mentor - -## Need to get help? - -If you'd like help solving the exercise, check the following pages: - -- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) -- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) -- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) - -Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. - -## Rust Installation - -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! - -If you want to know more about Exercism, take a look at the [contribution guide]. - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. - -[help-page]: https://exercism.org/tracks/rust/learning -[github]: https://github.com/exercism/rust -[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/exercism/rust/lucians-luscious-lasagna/HINTS.md b/exercism/rust/lucians-luscious-lasagna/HINTS.md deleted file mode 100644 index 5d1a5ff..0000000 --- a/exercism/rust/lucians-luscious-lasagna/HINTS.md +++ /dev/null @@ -1,31 +0,0 @@ -# Hints - -## General - -- An integer literal can be defined as one or more consecutive digits. - -## 1. Define the expected oven time in minutes - -- You need to define a [function][functions] without any parameters. - -## 2. Calculate the remaining oven time in minutes - -- You need to define a [function][functions] with a single parameter. -- You can use and refer to the previously defined item by its name. -- The last expression in a function is [automatically returned][return-values] from the function; you don't have to explicitly indicate which value to return. -- You can use the [mathematical operator for subtraction][operators] to subtract values. - -## 3. Calculate the preparation time in minutes - -- You need to define a [function][functions] with a single parameter. -- You can use the [mathematical operator for multiplicaton][operators] to multiply values. - -## 4. Calculate the elapsed time in minutes - -- You need to define a [function][functions] with two parameters. -- You can [call][functions] one of the other functions you've defined previously. -- You can use the [mathematical operator for addition][operators] to add values. - -[functions]: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html -[return-values]: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html#functions-with-return-values -[operators]: https://doc.rust-lang.org/book/appendix-02-operators.html \ No newline at end of file diff --git a/exercism/rust/lucians-luscious-lasagna/README.md b/exercism/rust/lucians-luscious-lasagna/README.md deleted file mode 100644 index 4e40672..0000000 --- a/exercism/rust/lucians-luscious-lasagna/README.md +++ /dev/null @@ -1,159 +0,0 @@ -# Lucian's Luscious Lasagna - -Welcome to Lucian's Luscious Lasagna on Exercism's Rust Track. -If you need help running the tests or submitting your code, check out `HELP.md`. -If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) - -## Introduction - -In Rust, assigning a value to a name is referred to as a _binding_. Bindings are immutable unless declared with the `mut` keyword. As Rust is a statically-typed language, each binding has a type known at compile-time. - -Bindings are most commonly defined using the `let` keyword. Specifying a binding's type is optional for most bindings, as Rust's _type inference_ can usually infer the type based on their value. A binding looks like this: - -```rust -// Automatically inferred type -let fingers = 10; -``` - -Functions are _items_. Where bindings typically refer to a particular value, items refer to a unit of code organization, typically a function or a module, which is available throughout the lifetime of the program. A function automatically returns the result of its last expression. A function may have 0 or more parameters, which are bindings with a lifetime of the function call. - -Type inference is theoretically possible for functions, but is disabled as an intentional language design choice. While this means that you need to spend a little more time when writing code to specify precisely what a function's input and output types are, you save the time when you're reading the code, because all the input and output types are explicitly defined. - -```rust -fn add(x: i32, y: i32) -> i32 { - x + y -} -``` - -Invoking a function is done by specifying its name followed by parentheses. If the function requires parameters, an argument must be specified for each within the parentheses. - -```rust -let five = add(2, 3); -``` - -If a binding's type cannot be inferred, the compiler will report an error. To fix this, add an explicit type annotation to the binding. - -```rust -// Explicit type annotation -let fingers: i32 = 10; -``` - -Items in Rust can be used before or after they are defined, because they have a static lifetime. Bindings, on the other hand, can only be used _after_ they have been defined. Using a binding before it has been defined results in a compile error. - -```rust -fn main() { - // `fn add` hasn't yet been defined, but that's perfectly ok - dbg!(add(3, 4)); -} - -fn add(x: i32, y: i32) -> i32 { - x + y -} -``` - -```rust -// this won't compile; `a` is used before its binding is defined -let b = a; -let a = x + y; -``` - -Rust uses curly braces (`{}`) to define a scope. A binding defined within a scope can't escape from it. - -```rust -let a = 1; -dbg!(a); // 1 -{ - // Here, we re-bind `a` to a new value, which is still immutable. - // This technique is called _shadowing_. The new binding is constrained to - // this anonymous scope. Outside this scope, the previous binding still - // applies. - let a = 2; - let b = 3; - dbg!(a, b); // 2, 3 -} -// can't use `b` anymore because it is out of scope -// dbg!(b); - -// The shadowed `a` in the inner scope above has fallen out of scope, -// leaving us with our original binding. -dbg!(a); // 1 -``` - -Rust items are often organized in modules. Each crate is implicitly a module, but it can define inner sub-modules of arbitrary depth. A module groups related functionality and is defined using the `mod` keyword. - -```rust -mod calc_i32 { - fn add(a: i32, b: i32) -> i32 { a + b } - fn sub(a: i32, b: i32) -> i32 { a - b } - fn mul(a: i32, b: i32) -> i32 { a * b } - fn div(a: i32, b: i32) -> i32 { a / b } -} -``` - -Rust supports two types of comments. The keyword `//` indicates a single-line comment; everything following the keyword until the end of the line is ignored. The keywords `/*` and `*/` indicate a multi-line comment; everything within those two keywords is ignored. It is idiomatic and good practice to prefer single-line comments. - -Rust also supports doc-comments, which show up in the generated documentation produced by `cargo doc`. Outer doc comments are formed with the keyword `///`, which acts identically to the `//` keyword. They apply to the item which follows them, such as a function: - -```rust -/// The `add` function produces the sum of its arguments. -fn add(x: i32, y: i32) -> i32 { x + y } -``` - -Inner doc comments are formed with the keyword `//!`, which acts identically to the `//` keyword. They apply to the item enclosing them, such as a module: - -```rust -mod my_cool_module { - //! This module is the bee's knees. -} -``` - -Doc comments can be of arbitrary length and contain markdown, which is rendered into the generated documentation. - -## Instructions - -In this exercise you're going to write some code to help you cook a brilliant lasagna from your favorite cooking book. - -You have four tasks, all related to the time spent cooking the lasagna. - -## 1. Define the expected oven time in minutes - -Define the `expected_minutes_in_oven` binding to check how many minutes the lasagna should be in the oven. According to the cooking book, the expected oven time in minutes is 40: - -```rust -expected_minutes_in_oven() -// Returns: 40 -``` - -## 2. Calculate the remaining oven time in minutes - -Define the `remaining_minutes_in_oven` function that takes the actual minutes the lasagna has been in the oven as a parameter and returns how many minutes the lasagna still has to remain in the oven, based on the expected oven time in minutes from the previous task. - -```rust -remaining_minutes_in_oven(30) -// Returns: 10 -``` - -## 3. Calculate the preparation time in minutes - -Define the `preparation_time_in_minutes` function that takes the number of layers you added to the lasagna as a parameter and returns how many minutes you spent preparing the lasagna, assuming each layer takes you 2 minutes to prepare. - -```rust -preparation_time_in_minutes(2) -// Returns: 4 -``` - -## 4. Calculate the elapsed time in minutes - -Define the `elapsed_time_in_minutes` function that takes two parameters: the first parameter is the number of layers you added to the lasagna, and the second parameter is the number of minutes the lasagna has been in the oven. The function should return how many minutes you've worked on cooking the lasagna, which is the sum of the preparation time in minutes, and the time in minutes the lasagna has spent in the oven at the moment. - -```rust -elapsed_time_in_minutes(3, 20) -// Returns: 26 -``` - -## Source - -### Created by - -- @coriolinus -- @ErikSchierboom \ No newline at end of file diff --git a/exercism/rust/lucians-luscious-lasagna/src/lib.rs b/exercism/rust/lucians-luscious-lasagna/src/lib.rs deleted file mode 100644 index 2f4787c..0000000 --- a/exercism/rust/lucians-luscious-lasagna/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This stub file contains items that aren't used yet; feel free to remove this module attribute -// to enable stricter warnings. - -pub fn expected_minutes_in_oven() -> i32 { - 40 -} - -pub fn remaining_minutes_in_oven(actual_minutes_in_oven: i32) -> i32 { - expected_minutes_in_oven() - actual_minutes_in_oven -} - -pub fn preparation_time_in_minutes(number_of_layers: i32) -> i32 { - number_of_layers * 2 -} - -pub fn elapsed_time_in_minutes(number_of_layers: i32, actual_minutes_in_oven: i32) -> i32 { - preparation_time_in_minutes(number_of_layers) + actual_minutes_in_oven -} diff --git a/exercism/rust/lucians-luscious-lasagna/tests/lucians-luscious-lasagna.rs b/exercism/rust/lucians-luscious-lasagna/tests/lucians-luscious-lasagna.rs deleted file mode 100644 index 340d476..0000000 --- a/exercism/rust/lucians-luscious-lasagna/tests/lucians-luscious-lasagna.rs +++ /dev/null @@ -1,34 +0,0 @@ -use lucians_luscious_lasagna::{ - elapsed_time_in_minutes, expected_minutes_in_oven, preparation_time_in_minutes, - remaining_minutes_in_oven, -}; - -#[test] -fn expected_minutes_in_oven_is_correct() { - assert_eq!(40, expected_minutes_in_oven()); -} - -#[test] -fn remaining_minutes_in_oven_after_fifteen_minutes() { - assert_eq!(15, remaining_minutes_in_oven(25)); -} - -#[test] -fn preparation_time_in_minutes_for_one_layer() { - assert_eq!(2, preparation_time_in_minutes(1)); -} - -#[test] -fn preparation_time_in_minutes_for_multiple_layers() { - assert_eq!(8, preparation_time_in_minutes(4)); -} - -#[test] -fn elapsed_time_in_minutes_for_one_layer() { - assert_eq!(32, elapsed_time_in_minutes(1, 30)); -} - -#[test] -fn elapsed_time_in_minutes_for_multiple_layers() { - assert_eq!(16, elapsed_time_in_minutes(4, 8)); -} diff --git a/exercism/rust/semi-structured-logs/.exercism/config.json b/exercism/rust/semi-structured-logs/.exercism/config.json deleted file mode 100644 index 6d9300e..0000000 --- a/exercism/rust/semi-structured-logs/.exercism/config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "authors": [ - "efx" - ], - "files": { - "solution": [ - "src/lib.rs", - "Cargo.toml" - ], - "test": [ - "tests/semi-structured-logs.rs" - ], - "exemplar": [ - ".meta/exemplar.rs" - ] - }, - "blurb": "Learn enums while building a logging utility." -} diff --git a/exercism/rust/semi-structured-logs/.exercism/metadata.json b/exercism/rust/semi-structured-logs/.exercism/metadata.json deleted file mode 100644 index 328771b..0000000 --- a/exercism/rust/semi-structured-logs/.exercism/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"track":"rust","exercise":"semi-structured-logs","id":"2e750e14b86e466caba76fda27e561db","url":"https://exercism.org/tracks/rust/exercises/semi-structured-logs","handle":"habys","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/exercism/rust/semi-structured-logs/.gitignore b/exercism/rust/semi-structured-logs/.gitignore deleted file mode 100644 index db7f315..0000000 --- a/exercism/rust/semi-structured-logs/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercism/rust/semi-structured-logs/Cargo.toml b/exercism/rust/semi-structured-logs/Cargo.toml deleted file mode 100644 index 166e966..0000000 --- a/exercism/rust/semi-structured-logs/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "semi_structured_logs" -version = "0.1.0" -edition = "2021" - -[features] -add-a-variant = [] - -[dependencies] diff --git a/exercism/rust/semi-structured-logs/HELP.md b/exercism/rust/semi-structured-logs/HELP.md deleted file mode 100644 index 7857ff6..0000000 --- a/exercism/rust/semi-structured-logs/HELP.md +++ /dev/null @@ -1,85 +0,0 @@ -# Help - -## Running the tests - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run _only ignored_ tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -If you are using Rust 1.51 or later, you can run _all_ tests with - -```bash -$ cargo test -- --include-ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored, use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the online [test documentation][rust-tests]. - -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Submitting your solution - -You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. -This command will upload your solution to the Exercism website and print the solution page's URL. - -It's possible to submit an incomplete solution which allows you to: - -- See how others have completed the exercise -- Request help from a mentor - -## Need to get help? - -If you'd like help solving the exercise, check the following pages: - -- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) -- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) -- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) - -Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. - -## Rust Installation - -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! - -If you want to know more about Exercism, take a look at the [contribution guide]. - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. - -[help-page]: https://exercism.org/tracks/rust/learning -[github]: https://github.com/exercism/rust -[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/exercism/rust/semi-structured-logs/HINTS.md b/exercism/rust/semi-structured-logs/HINTS.md deleted file mode 100644 index 1804e14..0000000 --- a/exercism/rust/semi-structured-logs/HINTS.md +++ /dev/null @@ -1,13 +0,0 @@ -# Hints - -## General - -- [Rust By Example - Enums][rbe-enums] -- [cheats.rs - Basic Types][cheats-types] - -## 1. Emit semi-structured messages - -- `match` comes in handy when working with enums. In this case, see how you might use it when figuring how what kind of log message to generate. - -[rbe-enums]: https://doc.rust-lang.org/stable/rust-by-example/custom_types/enum.html#enums -[cheats-types]: https://cheats.rs/#basic-types \ No newline at end of file diff --git a/exercism/rust/semi-structured-logs/README.md b/exercism/rust/semi-structured-logs/README.md deleted file mode 100644 index 955299c..0000000 --- a/exercism/rust/semi-structured-logs/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Semi Structured Logs - -Welcome to Semi Structured Logs on Exercism's Rust Track. -If you need help running the tests or submitting your code, check out `HELP.md`. -If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) - -## Introduction - -Enums, short for enumerations, are a type that limits all possible values of some data. The possible values of an `enum` are called variants. Enums also work well with `match` and other control flow operators to help you express intent in your Rust programs. - -## Instructions - -In this exercise you'll be generating semi-structured log messages. - -## 1. Emit semi-structured messages - -You'll start with some stubbed functions and the following enum: - -```rust -#[derive(Clone, PartialEq, Debug)] -pub enum LogLevel { - Info, - Warning, - Error, -} -``` - -Your goal is to emit a log message as follows: `"[]: "`. -You'll need to implement functions that correspond with log levels. - -For example, the below snippet demonstrates an expected output for the `log` function. - -```rust -log(LogLevel::Error, "Stack overflow") -// Returns: "[ERROR]: Stack overflow" -``` - -And for `info`: - -```rust -info("Timezone changed") -// Returns: "[INFO]: Timezone changed" -``` - -Have fun! - -## 2. Optional further practice - -There is a feature-gated test in this suite. -Feature gates disable compilation entirely for certain sections of your program. -They will be covered later. -For now just know that there is a test which is only built and run when you use a special testing invocation: - -```sh -cargo test --features add-a-variant -``` - -This test is meant to show you how to add a variant to your enum. - -## Source - -### Created by - -- @efx \ No newline at end of file diff --git a/exercism/rust/semi-structured-logs/src/lib.rs b/exercism/rust/semi-structured-logs/src/lib.rs deleted file mode 100644 index ed35334..0000000 --- a/exercism/rust/semi-structured-logs/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This stub file contains items that aren't used yet; feel free to remove this module attribute -// to enable stricter warnings. - -/// various log levels -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum LogLevel { - Debug, - Info, - Warning, - Error, -} -/// primary function for emitting logs -pub fn log(level: LogLevel, message: &str) -> String { - match level { - LogLevel::Debug => debug(&message), - LogLevel::Info => info(&message), - LogLevel::Warning => warn(&message), - LogLevel::Error => error(&message), - } -} -pub fn debug(message: &str) -> String { - format!("[DEBUG]: {message}") -} -pub fn info(message: &str) -> String { - format!("[INFO]: {message}") -} -pub fn warn(message: &str) -> String { - format!("[WARNING]: {message}") -} -pub fn error(message: &str) -> String { - format!("[ERROR]: {message}") -} diff --git a/exercism/rust/semi-structured-logs/tests/semi-structured-logs.rs b/exercism/rust/semi-structured-logs/tests/semi-structured-logs.rs deleted file mode 100644 index fec5b1b..0000000 --- a/exercism/rust/semi-structured-logs/tests/semi-structured-logs.rs +++ /dev/null @@ -1,53 +0,0 @@ -use semi_structured_logs::{error, info, log, warn, LogLevel}; - -#[test] -fn emits_info() { - assert_eq!(info("Timezone changed"), "[INFO]: Timezone changed"); -} - -#[test] -//#[ignore] -fn emits_warning() { - assert_eq!(warn("Timezone not set"), "[WARNING]: Timezone not set"); -} - -#[test] -//#[ignore] -fn emits_error() { - assert_eq!(error("Disk full"), "[ERROR]: Disk full"); -} - -#[test] -//#[ignore] -fn log_emits_info() { - assert_eq!( - log(LogLevel::Info, "Timezone changed"), - "[INFO]: Timezone changed" - ); -} - -#[test] -//#[ignore] -fn log_emits_warning() { - assert_eq!( - log(LogLevel::Warning, "Timezone not set"), - "[WARNING]: Timezone not set" - ); -} - -#[test] -//#[ignore] -fn log_emits_error() { - assert_eq!(log(LogLevel::Error, "Disk full"), "[ERROR]: Disk full"); -} - -#[test] -#[cfg(feature = "add-a-variant")] -//#[ignore] -fn add_a_variant() { - // this test won't even compile until the enum is complete, which is why it is feature-gated. - assert_eq!( - log(LogLevel::Debug, "reached line 123"), - "[DEBUG]: reached line 123", - ); -} diff --git a/guessing_game/Cargo.toml b/guessing_game/Cargo.toml deleted file mode 100644 index cc63f6f..0000000 --- a/guessing_game/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "guessing_game" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -rand = "0.8.3" diff --git a/guessing_game/src/main.rs b/guessing_game/src/main.rs deleted file mode 100644 index 65f0155..0000000 --- a/guessing_game/src/main.rs +++ /dev/null @@ -1,58 +0,0 @@ -// some things are automatically loaded in every rust program -// https://doc.rust-lang.org/std/prelude/index.html -// for extras, import them with `use`: -use std::io; -use std::cmp::Ordering; -use rand::Rng; - -fn main() { - println!("Guess the number!"); - println!("input your guess"); - // ..= is inclusive - let secret_number = rand::thread_rng().gen_range(1..=100); - println!("The secret number is: {secret_number}"); - // vars are immutable by default, change this - // The :: syntax in the ::new line indicates that new is an _associated function_ of the String - // a function that’s implemented on a type - // could still call this without importing it via std::io::stdin - // this can be one line, it is broken up for readability. - loop { - let mut guess = String::new(); - io::stdin() - // & indicates that this argument is a reference, - // references are also immutable by default so &mut is needed - .read_line(&mut guess) - // expect handles the Err variant by crashing the program. There are other ways to handle - // errors. - .expect("Failed to read line"); - // read_line returns a `result` value. result is an enum. Each possible state is a variant. - // Result's variants are Ok and Err - - // shadowing V - // change from expect which crashes all the time to match - // to perform an action depending on the value of the enum - let guess: u32 = match guess.trim().parse() { - Ok(num) => num, - Err(_) => { - println!("that aint no number I ever heard of"); - continue; - } - }; - // trim removes space and \n - // single colon is type annotation - // - println!("you guessed: {guess}"); - // a match expression is made of arms. an arm is a pattern to match and code to run against it. - // switch/case - match guess.cmp(&secret_number) { - Ordering::Less => println!("too small"), - Ordering::Greater => println!("too big"), - Ordering::Equal => { - println!("you win"); - break; - } - } - } -} -// cargo doc --open -// generate doc about this code and dependancies diff --git a/hello_cargo/.gitignore b/hello_cargo/.gitignore deleted file mode 100644 index fa8d85a..0000000 --- a/hello_cargo/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Cargo.lock -target diff --git a/hello_cargo/Cargo.toml b/hello_cargo/Cargo.toml deleted file mode 100644 index 19c7b36..0000000 --- a/hello_cargo/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "hello_cargo" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/hello_cargo/src/main.rs b/hello_cargo/src/main.rs deleted file mode 100644 index 65e6e73..0000000 --- a/hello_cargo/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("ǰ DZ Dz dz Ǵ ǵ Ƕ Ƿ Ǹ ǹ Ǻ ǻ Ǽ ǽ Ǿ"); -} diff --git a/ownership/Cargo.toml b/ownership/Cargo.toml deleted file mode 100644 index 302f515..0000000 --- a/ownership/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "ownership" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/ownership/src/main.rs b/ownership/src/main.rs deleted file mode 100644 index 9c397e5..0000000 --- a/ownership/src/main.rs +++ /dev/null @@ -1,43 +0,0 @@ -fn main() { - let mut s = String::from("farts"); - let s2 = String::from("farts"); - s.push_str(" and blarts"); - println!("Hello, {s}!"); - - s = String::from("hello"); - takes_ownership(s.clone()); - takes_ownership(s.clone()); - let r1 = &mut s; - takes_ref(r1); - let r2 = &mut s; - takes_ref(r2); - //takes_ref(r1); - let x = 5; - makes_copy(x); - let s3 = take_and_give_back(s); - println!("cha cha cha {}", s3); - let s4 = take_and_give_back(String::from("farts")); - let s5 = take_and_give_back(s2); - - - println!("cha cha cha {} {}", s4, s5); - -} - -fn take_and_give_back(mut some_string: String) -> String { - some_string.push_str("caflobble"); - some_string -} - -fn takes_ref(some_string: &mut String) { - some_string.push_str("sdf"); - println!("{}", some_string); -} - -fn takes_ownership(some_string: String) { - println!("{}", some_string); -} - -fn makes_copy(some_int: u8) { - println!("some int: {}", some_int); -} diff --git a/plants b/plants deleted file mode 100644 index 6d17a63..0000000 --- a/plants +++ /dev/null @@ -1,24 +0,0 @@ -green shiso -green shiso -marvel of seasons -flower -parris island -rouge d'hiver -rouge d'hiver -flower -marvel of seasons -marvel of seasons -rouge d'hiver -flower -rouge d'hiver -parris island -black seeded simpson -flower -chives -black seeded simpson -dill -flower -red sails -genovese basil -deer tongue -48 flower diff --git a/rust_book/02/guessing_game b/rust_book/02/guessing_game new file mode 160000 index 0000000..da0a40d --- /dev/null +++ b/rust_book/02/guessing_game @@ -0,0 +1 @@ +Subproject commit da0a40d5d32559f6e33056401d84404c04c25c83 diff --git a/slice/Cargo.toml b/slice/Cargo.toml deleted file mode 100644 index 7216848..0000000 --- a/slice/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "slice" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/slice/src/main.rs b/slice/src/main.rs deleted file mode 100644 index de08fcd..0000000 --- a/slice/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -fn first_word_int(s: &str) -> usize { - let b = s.as_bytes(); - for (i, &val) in b.iter().enumerate() { - if val == b' ' { - return i; - } - } - s.len() -} - -fn first_word(s: &str) -> &str { - let b = s.as_bytes(); - for (i, &val) in b.iter().enumerate() { - if val == b' ' { - return &s[..i]; - } - } - &s[..] -} -fn main() { - let test_string = "oh my gerd"; - let string = String::from("sdf sdf esv gs "); - let slice = &string[0..first_word_int(&string)]; - println!("here is the first word: _{}_", slice); - - println!("here is the first word: _{}_", first_word(&string)); - println!("here is the first word: _{}_", first_word(test_string)); - println!("{}", test_string); -} diff --git a/tuple1/Cargo.toml b/tuple1/Cargo.toml deleted file mode 100644 index d63cf88..0000000 --- a/tuple1/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "tuple1" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/tuple1/src/main.rs b/tuple1/src/main.rs deleted file mode 100644 index 03f583e..0000000 --- a/tuple1/src/main.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let x: (i32, f64, u8) = (500, 6.4, 1); - let _five_hundred = x.0; - let _six_point_four = x.1; - let _one = x.2; -}