From a699803ce717f16779a44d4e9b55ae76c26a3dde Mon Sep 17 00:00:00 2001 From: rrokkam Date: Sun, 19 Jul 2020 12:33:57 -0700 Subject: [PATCH] cargo fmt Standard Rust formatting practice --- rust/src/gildedrose/mod.rs | 18 +++++++++++------- rust/src/gildedrose/test.rs | 2 +- rust/src/main.rs | 23 +++++++++++++++++------ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/rust/src/gildedrose/mod.rs b/rust/src/gildedrose/mod.rs index f055f99d..17314625 100644 --- a/rust/src/gildedrose/mod.rs +++ b/rust/src/gildedrose/mod.rs @@ -4,35 +4,39 @@ use std::vec; pub struct Item { pub name: string::String, pub sell_in: i32, - pub quality: i32 + pub quality: i32, } impl Item { pub fn new(name: String, sell_in: i32, quality: i32) -> Item { - Item {name: name, sell_in: sell_in, quality: quality} + Item { + name: name, + sell_in: sell_in, + quality: quality, + } } } pub struct GildedRose { - pub items: vec::Vec + pub items: vec::Vec, } impl GildedRose { pub fn new(items: vec::Vec) -> GildedRose { - GildedRose {items: items} + GildedRose { items: items } } pub fn update_quality(&mut self) { for item in &mut self.items { - if item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert" { + if item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert" + { if item.quality > 0 { if item.name != "Sulfuras, Hand of Ragnaros" { item.quality = item.quality - 1; } } } else { - if item.quality < 50 - { + if item.quality < 50 { item.quality = item.quality + 1; if item.name == "Backstage passes to a TAFKAL80ETC concert" { diff --git a/rust/src/gildedrose/test.rs b/rust/src/gildedrose/test.rs index afc11c88..1883cc40 100644 --- a/rust/src/gildedrose/test.rs +++ b/rust/src/gildedrose/test.rs @@ -1,4 +1,4 @@ -use super::{Item, GildedRose}; +use super::{GildedRose, Item}; #[test] pub fn foo() { diff --git a/rust/src/main.rs b/rust/src/main.rs index b56d07e6..22da85fb 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,7 +1,6 @@ - mod gildedrose; -use gildedrose::{Item, GildedRose}; +use gildedrose::{GildedRose, Item}; fn main() { let items = vec![ @@ -10,11 +9,23 @@ fn main() { Item::new(String::from("Elixir of the Mongoose"), 5, 7), Item::new(String::from("Sulfuras, Hand of Ragnaros"), 0, 80), Item::new(String::from("Sulfuras, Hand of Ragnaros"), -1, 80), - Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 15, 20), - Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 10, 49), - Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 5, 49), + Item::new( + String::from("Backstage passes to a TAFKAL80ETC concert"), + 15, + 20, + ), + Item::new( + String::from("Backstage passes to a TAFKAL80ETC concert"), + 10, + 49, + ), + Item::new( + String::from("Backstage passes to a TAFKAL80ETC concert"), + 5, + 49, + ), // this conjured item does not work properly yet - Item::new(String::from("Conjured Mana Cake"), 3, 6) + Item::new(String::from("Conjured Mana Cake"), 3, 6), ]; let mut rose = GildedRose::new(items);