From 66f2f1db23ad3d4d4b86171bd082f2090853935b Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Fri, 26 May 2023 01:03:08 -0400 Subject: [PATCH] page 111 --- .vimspector.json | 30 ++++++++++++++++++++++++++++++ chapter6/.vimspector.json | 10 ++++++++++ chapter6/coins/.vimspector.json | 10 ++++++++++ chapter6/coins/Cargo.lock | 7 +++++++ chapter6/coins/Cargo.toml | 8 ++++++++ chapter6/coins/src/main.rs | 24 ++++++++++++++++++++++++ justfile | 2 +- 7 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .vimspector.json create mode 100644 chapter6/.vimspector.json create mode 100644 chapter6/coins/.vimspector.json create mode 100644 chapter6/coins/Cargo.lock create mode 100644 chapter6/coins/Cargo.toml create mode 100644 chapter6/coins/src/main.rs diff --git a/.vimspector.json b/.vimspector.json new file mode 100644 index 0000000..a18cdd4 --- /dev/null +++ b/.vimspector.json @@ -0,0 +1,30 @@ +-e { "configurations": { "launch": { + "adapter": "CodeLLDB", + "filetypes": [ "rust" ], + "configuration": { + "request": "launch", + "program": "${workspaceRoot}/target/debug/rectangles" + } + } + } + } +-e { "configurations": { "launch": { + "adapter": "CodeLLDB", + "filetypes": [ "rust" ], + "configuration": { + "request": "launch", + "program": "${workspaceRoot}/target/debug/rectangles" + } + } + } + } +-e { "configurations": { "launch": { + "adapter": "CodeLLDB", + "filetypes": [ "rust" ], + "configuration": { + "request": "launch", + "program": "${workspaceRoot}/target/debug/HERE" + } + } + } + } diff --git a/chapter6/.vimspector.json b/chapter6/.vimspector.json new file mode 100644 index 0000000..fc7608f --- /dev/null +++ b/chapter6/.vimspector.json @@ -0,0 +1,10 @@ +{ "configurations": { "launch": { + "adapter": "CodeLLDB", + "filetypes": [ "rust" ], + "configuration": { + "request": "launch", + "program": "${workspaceRoot}/target/debug/HERE" + } + } + } + } diff --git a/chapter6/coins/.vimspector.json b/chapter6/coins/.vimspector.json new file mode 100644 index 0000000..3d3dfff --- /dev/null +++ b/chapter6/coins/.vimspector.json @@ -0,0 +1,10 @@ +{ "configurations": { "launch": { + "adapter": "CodeLLDB", + "filetypes": [ "rust" ], + "configuration": { + "request": "launch", + "program": "${workspaceRoot}/target/debug/coins" + } + } + } + } diff --git a/chapter6/coins/Cargo.lock b/chapter6/coins/Cargo.lock new file mode 100644 index 0000000..ca528d6 --- /dev/null +++ b/chapter6/coins/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "coins" +version = "0.1.0" diff --git a/chapter6/coins/Cargo.toml b/chapter6/coins/Cargo.toml new file mode 100644 index 0000000..77e85aa --- /dev/null +++ b/chapter6/coins/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "coins" +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/chapter6/coins/src/main.rs b/chapter6/coins/src/main.rs new file mode 100644 index 0000000..d95cf4c --- /dev/null +++ b/chapter6/coins/src/main.rs @@ -0,0 +1,24 @@ +enum Coin { + Penny, + Nickel, + Dime, + Quarter, +} + +fn value_in_cents(coin: Coin) -> u8 { + match coin { + Coin::Penny => 1, + Coin::Nickel => 5, + Coin::Dime => 10, + Coin::Quarter => 25, + } + +} + +fn main() { + println!("Hello, world!"); + let v: u8 = value_in_cents(Coin::Dime); + let s: String = v.to_string(); + println!("{}", s); + +} diff --git a/justfile b/justfile index df1b153..ccaca20 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ #!/usr/bin/env -S just --justfile vimspector: - echo -e "{ \"configurations\": { \"launch\": {\n \"adapter\": \"CodeLLDB\",\n \"filetypes\": [ \"rust\" ],\n \"configuration\": {\n \"request\": \"launch\",\n \"program\": \"\${workspaceRoot}/target/debug/rectangles\"\n }\n }\n }\n }" >> ./.vimspector.json + echo -e "{ \"configurations\": { \"launch\": {\n \"adapter\": \"CodeLLDB\",\n \"filetypes\": [ \"rust\" ],\n \"configuration\": {\n \"request\": \"launch\",\n \"program\": \"\${workspaceRoot}/target/debug/HERE\"\n }\n }\n }\n }" >> ./.vimspector.json p: