The elves were huddled at a desk, deep in debate over their Neovim setups.
“I finally nailed my init.lua
,” said Sparky. “Switched to bspwm
, too. Total game-changer.”
“Pfft,” Tinker scoffed. “Real pros stick to Vimscript. You don’t need all those plugins.”
Jingle sipped his eggnog. “I wrote a whole game in Vim once. Problem? Couldn’t press two keys at the same time. Now it’s turn-based.”
Before they could laugh, the door slammed open. Santa stormed in once again. “Do I pay you to yap about text editors?”
The elves froze as Santa tossed a crumpled piece of code onto the table. “The sleigh builder is completely broken! I just tried to build a sleigh, and it’s missing half the parts. Magical enhancements? Gone. Gift capacity? Zero. Someone explain this!”
Sparky glanced at the code and gulped. “This… uh… looks like something from that old project nobody touched.”
“Exactly!” Santa growled. “And now it’s ruining everything. We’re rewriting this in Rust. Get to work, before I replace you all with AI!”
To help Santa build his new sleigh easily, we need to create him a SleighBuilder
that can build and return Sleigh
instances.
The SleighBuilder
should have:
new
that creates a new SleighBuilder
instance.red
, reindeer-powered
, 100
, and false
are the default values for the sleigh.color
that takes a &str
and sets the color of the sleigh.engine
that takes a &str
and sets the engine of the sleigh.gift_capacity
that accepts a u32
and sets the gift capacity of the sleigh.magical_enhancements
that sets the magical enhancements of the sleigh.Sleigh
instance called build
.Make sure that each method takes ownership of the SleighBuilder
instance and returns it after mutation.
Have a look at the end of the file to see how Santa wants to use this API.
If you're stuck or need a starting point, here are some hints to help you along the way!
SleighBuilder
struct and return a Sleigh
instance when the build
method is called.pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here default_color: String, default_engine: String, default_gift_capacity: u32, defaultmagical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { Self { default_color: "red".to_string(), default_engine: "reindeer-powered".to_string(), default_gift_capacity: 100, defaultmagical_enhancements: false, } } // Your code here... pub fn build(self) -> Sleigh { Sleigh { color: self.default_color.clone(), engine: self.default_engine.clone(), gift_capacity: self.default_gift_capacity, magical_enhancements: self.defaultmagical_enhancements, } } pub fn color(mut self, color: &str) -> Self { self.default_color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.default_engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.default_gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self{ self.defaultmagical_enhancements = true; self }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here sleigh: Sleigh,}impl SleighBuilder { // Your code here... pub fn new() -> Self { return SleighBuilder { sleigh: Sleigh { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false } } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = String::from(color); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = String::from(engine); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.sleigh.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here sleigh: Sleigh,}impl SleighBuilder { // Your code here... pub fn new() -> Self { return SleighBuilder { sleigh: Sleigh { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false } } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = String::from(color); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = String::from(engine); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.sleigh.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool}impl SleighBuilder { pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool}impl SleighBuilder { pub fn new() -> SleighBuilder { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, color: &str) -> SleighBuilder { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> SleighBuilder { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, v: u32) -> SleighBuilder { self.gift_capacity = v; self } pub fn magical_enhancements(mut self)-> SleighBuilder { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { Self { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, c: &str) -> Self { self.color = c.to_string(); self } pub fn engine(mut self, e: &str) -> Self { self.engine = e.to_string(); self } pub fn gift_capacity(mut self, gc: u32) -> Self { self.gift_capacity = gc; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) ->Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) ->Self { self.magical_enhancements = true; self } pub fn build (self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) ->Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) ->Self { self.magical_enhancements = true; self } pub fn build (self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new () -> Self{ SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color (mut self, color: &str) -> Self{ self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self{ self.engine = engine.to_string(); self } pub fn gift_capacity (mut self, capacity: u32) -> Self{ self.gift_capacity = capacity; self } pub fn magical_enhancements (mut self) -> Self{ self.magical_enhancements = true; self } pub fn build (self) -> Sleigh { Sleigh{ color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements } }pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { Self { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, cap: u32) -> Self { self.gift_capacity = cap; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { sleigh: Sleigh,}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { sleigh: Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, }, } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, n: u32) -> Self { self.sleigh.gift_capacity = n; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh } // Your code here...}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> SleighBuilder { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, value: &str) -> Self { self.color = value.to_string(); self } pub fn engine(mut self, value: &str) -> Self { self.engine = value.to_string(); self } pub fn gift_capacity(mut self, value: u32) -> Self { self.gift_capacity = value; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, capacity: u32, enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder<'a> { // Define the fields of SleighBuilder here color: &'a str, engine: &'a str, capacity: u32, enhancements: bool,}impl<'a> SleighBuilder<'a> { // Your code here... pub fn new() -> Self { Self { color: "red", engine: "reindeer-powered", capacity: 100, enhancements: false, } } pub fn color(mut self, color: &'a str) -> Self { self.color = color; self } pub fn engine(mut self, engine: &'a str) -> Self { self.engine = engine; self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color.to_string(), engine: self.engine.to_string(), capacity: self.capacity, enhancements: self.enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.capacity } pub fn magical_enhancements(&self) -> bool { self.enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here sleigh: Sleigh,}impl Default for Sleigh{ fn default() -> Self { Self{ color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } }}impl SleighBuilder { // Your code here... pub fn new() -> Self{ Self{ sleigh: Default::default(), } } pub fn color(mut self, color: &str) -> Self{ self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self{ self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self{ self.sleigh.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) ->Self{ self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh{ self.sleigh.clone() }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements().clone() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, c: &str) -> Self { self.color = c.to_string(); self } pub fn engine(mut self, e: &str) -> Self { self.engine = e.to_string(); self } pub fn gift_capacity(mut self, g: u32) -> Self { self.gift_capacity = g; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, c: &str) -> Self { self.color = c.to_string(); self } pub fn engine(mut self, e: &str) -> Self { self.engine = e.to_string(); self } pub fn gift_capacity(mut self, cap: u32) -> Self { self.gift_capacity = cap; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> SleighBuilder { // Create a SleighBuilder instance SleighBuilder { color: "red".into(), engine: "reindeer-powered".into(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> SleighBuilder { self.color = color.into(); self } pub fn engine(mut self, engine: &str) -> SleighBuilder { self.engine = engine.into(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> SleighBuilder { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> SleighBuilder { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> SleighBuilder { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = String::from(color); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = String::from(engine); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, cap: u32) -> Self { self.gift_capacity = cap; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh{ color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity.clone(), magical_enhancements: self.magical_enhancements.clone(), } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl Sleigh { pub fn new(color: String, engine: String, gift_capacity: u32, magical_enhancements: bool) -> Self { Self { color, engine, gift_capacity, magical_enhancements, } }}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(self, color: &str) -> Self { Self { color: color.to_string(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.to_string(), ..self } } pub fn gift_capacity(self, gift_capacity: u32) -> Self { Self { gift_capacity, ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self } } pub fn build(&self) -> Sleigh { Sleigh::new(self.color.clone(), self.engine.clone(), self.gift_capacity, self.magical_enhancements) }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { sleigh: Sleigh, }impl SleighBuilder { pub fn new() -> Self { Self { sleigh: Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, }, } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.sleigh.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { self.sleigh.clone() }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { sleigh: Sleigh, }impl SleighBuilder { pub fn new() -> Self { Self { sleigh: Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, }, } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.sleigh.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh.clone() }}impl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> SleighBuilder { let color = "red".to_string(); let engine = "reindeer-powered".to_string(); let gift_capacity = 100; let magical_enhancements = false; SleighBuilder{ color, engine, gift_capacity, magical_enhancements, } } pub fn color(mut self, v: &str) -> Self { self.color = v.to_owned(); self } pub fn engine(mut self, v: &str) -> Self { self.engine = v.to_owned(); self } pub fn gift_capacity(mut self, v: u32) -> Self { self.gift_capacity = v; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh{ color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); return self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); return self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; return self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; return self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false, } } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, cap: u32) -> Self { self.gift_capacity = cap; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(self, color: &str) -> Self { Self { color: color.into(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.into(), ..self } } pub fn gift_capacity(self, gift_capacity: u32) -> Self { Self { gift_capacity: gift_capacity.into(), ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self } } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { SleighBuilder::default() } pub fn color(mut self, color: &str) -> Self{ self.color = color.to_string(); return self } pub fn engine(mut self, engine: &str) -> Self{ self.engine = engine.to_string(); return self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; return self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; return self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}impl Default for SleighBuilder { fn default() -> Self { SleighBuilder { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn gift_capacity(self, capacity: u32) -> Self { Self { gift_capacity: capacity, ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self } } pub fn color(self, color: &str) -> Self { Self { color: color.to_string(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.to_string(), ..self } } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn gift_capacity(self, capacity: u32) -> Self { Self { gift_capacity: capacity, ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self } } pub fn color(self, color: &str) -> Self { Self { color: color.to_string(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.to_string(), ..self } } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn gift_capacity(self, capacity: u32) -> Self { Self { gift_capacity: capacity, ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self } } pub fn color(self, color: &str) -> Self { Self { color: color.to_string(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.to_string(), ..self } } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool}impl SleighBuilder { pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity: u32) -> Self { self.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here pub sleigh: Sleigh,}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { sleigh: Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, }, } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.sleigh.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh } // Your code here...}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here // just return an instance of the Sleigh struct pub sleigh: Sleigh,}impl SleighBuilder { // Your code here... pub fn new() ->Self { SleighBuilder { sleigh : Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity:u32) -> Self { self.sleigh.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".into(), engine: "reindeer-powered".into(), gift_capacity: 100, magical_enhancements: false } } pub fn color(self, color: &str) -> Self { Self { color: color.into(), ..self } } pub fn engine(self, engine: &str) -> Self { Self { engine: engine.into(), ..self } } pub fn gift_capacity(self, capacity: u32) -> Self { Self { gift_capacity: capacity, ..self } } pub fn magical_enhancements(self) -> Self { Self { magical_enhancements: true, ..self} } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> SleighBuilder { SleighBuilder{ color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> SleighBuilder { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> SleighBuilder { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> SleighBuilder { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> SleighBuilder { self.magical_enhancements = true; self } pub fn build( self) -> Sleigh { Sleigh{ color: self.color.to_string(), engine: self.engine.to_string(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> SleighBuilder { SleighBuilder{ color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> SleighBuilder { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> SleighBuilder { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> SleighBuilder { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> SleighBuilder { self.magical_enhancements = true; self } pub fn build( self) -> Sleigh { Sleigh{ color: self.color.to_string(), engine: self.engine.to_string(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { b_color: String, b_engine: String, b_gift_capacity: u32, b_magical_enhancements: bool,}impl SleighBuilder { pub fn new() -> SleighBuilder{ SleighBuilder { b_color : "red".to_string(), b_engine : "reindeer-powered".to_string(), b_gift_capacity : 100, b_magical_enhancements : false, } } pub fn color(mut self, col: &str) -> SleighBuilder { self.b_color = col.to_string(); self } pub fn engine(mut self, engine: &str ) -> SleighBuilder { self.b_engine = engine.to_string(); self } pub fn gift_capacity(mut self, capa: u32 ) -> SleighBuilder { self.b_gift_capacity = capa; self } pub fn magical_enhancements(mut self) -> SleighBuilder { self.b_magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.b_color.clone(), engine: self.b_engine.clone(), gift_capacity: self.b_gift_capacity, magical_enhancements: self.b_magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: String::from("red"), engine: String::from("reindeer-powered"), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = String::from(color); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = String::from(engine); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.color.clone(), engine: self.engine.clone(), gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Default)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone, Default)]pub struct SleighBuilder { bcolor: String, bengine: String, bgift_capacity: u32, bmagical_enhancements: bool,}impl SleighBuilder { pub fn new() -> SleighBuilder { SleighBuilder { bcolor: String::from("red"), bengine: "reindeer-powered".to_string(), bgift_capacity: 100, bmagical_enhancements: false, } } pub fn color(mut self, color: &str) -> SleighBuilder { self.bcolor = color.to_string(); self } pub fn engine(mut self, engine: &str) -> SleighBuilder { self.bengine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity: u32) -> SleighBuilder { self.bgift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> SleighBuilder { self.bmagical_enhancements = true; self } pub fn build(&self) -> Sleigh { Sleigh { color: self.bcolor.clone(), engine: self.bengine.clone(), gift_capacity: self.bgift_capacity, magical_enhancements: self.bmagical_enhancements, } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here color: String, engine: String, gift_capacity: u32, magical_enhancements: bool}impl SleighBuilder { // Your code here... pub fn new() -> Self { Self { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_string(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { sleigh: Sleigh}impl SleighBuilder { pub fn new() -> Self { Self { sleigh: Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false } } } pub fn color(mut self, c: &str) -> Self { self.sleigh.color = c.to_string(); self } pub fn engine(mut self, e: &str) -> Self { self.sleigh.engine = e.to_string(); self } pub fn gift_capacity(mut self, g: u32) -> Self { self.sleigh.gift_capacity = g; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { // Define the fields of SleighBuilder here // just return an instance of the Sleigh struct pub sleigh: Sleigh,}impl SleighBuilder { // Your code here... pub fn new() ->Self { SleighBuilder { sleigh : Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false, } } } pub fn color(mut self, color: &str) -> Self { self.sleigh.color = color.to_string(); self } pub fn engine(mut self, engine: &str) -> Self { self.sleigh.engine = engine.to_string(); self } pub fn gift_capacity(mut self, capacity:u32) -> Self { self.sleigh.gift_capacity = capacity; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(self) -> Sleigh { self.sleigh }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { pub sleigh: Sleigh,}impl SleighBuilder { pub fn new() -> Self { Self { sleigh : Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false }} } pub fn color(mut self, s: &str) -> Self { self.sleigh.color = s.to_string(); self } pub fn engine(mut self, s: &str) -> Self { self.sleigh.engine = s.to_string(); self } pub fn gift_capacity(mut self, s: u32) -> Self { self.sleigh.gift_capacity = s; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { self.sleigh.clone() }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
#[derive(Clone)]pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { pub sleigh: Sleigh,}impl SleighBuilder { pub fn new() -> Self { Self { sleigh : Sleigh { color: "red".to_string(), engine: "reindeer-powered".to_string(), gift_capacity: 100, magical_enhancements: false }} } pub fn color(mut self, s: &str) -> Self { self.sleigh.color = s.to_string(); self } pub fn engine(mut self, s: &str) -> Self { self.sleigh.engine = s.to_string(); self } pub fn gift_capacity(mut self, s: u32) -> Self { self.sleigh.gift_capacity = s; self } pub fn magical_enhancements(mut self) -> Self { self.sleigh.magical_enhancements = true; self } pub fn build(&self) -> Sleigh { self.sleigh.clone() }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}
pub struct Sleigh { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool,}#[derive(Clone)]pub struct SleighBuilder { color: String, engine: String, gift_capacity: u32, magical_enhancements: bool, // Define the fields of SleighBuilder here}impl SleighBuilder { pub fn new() -> Self { SleighBuilder { color: "red".into(), engine: "reindeer-powered".into(), gift_capacity: 100, magical_enhancements: false, } } pub fn color(mut self, color: &str) -> Self { self.color = color.to_owned(); self } pub fn engine(mut self, engine: &str) -> Self { self.engine = engine.to_owned(); self } pub fn gift_capacity(mut self, gift_capacity: u32) -> Self { self.gift_capacity = gift_capacity; self } pub fn magical_enhancements(mut self) -> Self { self.magical_enhancements = true; self } pub fn build(self) -> Sleigh { Sleigh { color: self.color, engine: self.engine, gift_capacity: self.gift_capacity, magical_enhancements: self.magical_enhancements } }}// Don't Change this implementation// It is used for the testsimpl Sleigh { pub fn color(&self) -> &str { &self.color } pub fn engine(&self) -> &str { &self.engine } pub fn gift_capacity(&self) -> u32 { self.gift_capacity } pub fn magical_enhancements(&self) -> bool { self.magical_enhancements }}pub fn main() { let sleigh = SleighBuilder::new() .color("gold") .engine("magic") .gift_capacity(350) .magical_enhancements() .build(); assert_eq!(sleigh.color(), "gold"); assert_eq!(sleigh.engine(), "magic"); assert_eq!(sleigh.gift_capacity(), 350); assert_eq!(sleigh.magical_enhancements(), true);}