mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 15:01:28 +00:00
This clears a lot of Rust-specific String boilerplate, so it's not
necessary to type String::from("foo") every time we want an item
with name "foo". It also makes the code look more similar to the C#
version of the code.
I am leaving the public struct members in because those are more
similar to the matching code in the other languages' implementations.
31 lines
983 B
Rust
31 lines
983 B
Rust
mod gildedrose;
|
|
|
|
use gildedrose::{GildedRose, Item};
|
|
|
|
fn main() {
|
|
let items = vec![
|
|
Item::new("+5 Dexterity Vest", 10, 20),
|
|
Item::new("Aged Brie", 2, 0),
|
|
Item::new("Elixir of the Mongoose", 5, 7),
|
|
Item::new("Sulfuras, Hand of Ragnaros", 0, 80),
|
|
Item::new("Sulfuras, Hand of Ragnaros", -1, 80),
|
|
Item::new("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
|
Item::new("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
|
Item::new("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
|
// this conjured item does not work properly yet
|
|
Item::new("Conjured Mana Cake", 3, 6),
|
|
];
|
|
let mut rose = GildedRose::new(items);
|
|
|
|
println!("OMGHAI!");
|
|
for i in 0..30 {
|
|
println!("-------- day {} --------", i);
|
|
println!("name, sellIn, quality");
|
|
for item in &rose.items {
|
|
println!("{}", item);
|
|
}
|
|
println!();
|
|
rose.update_quality();
|
|
}
|
|
}
|