The elves trudged into the North Pole office, their little faces as frosty as leftover cocoa. The holiday crunch was bad enough, but Blitzen’s latest antics had turned it into a nightmare. As the self-appointed “Tech Lead,” Blitzen wouldn’t stop yapping about optimizing Rust code that didn’t need optimizing. Meanwhile, the real issues in Santa’s repo—the gift filtering bug and the broken nice-kid calculator—were piling up like unwrapped presents on December 24th.
The elves slumped into their desks, morale at absolute zero. That’s when Santa stomped into the room, red-faced and gripping his enormous candy cane staff. His expression said it all: Unhinged Santa Mode Activated.
“WHAT IN THE NAME OF PRANCER’S LEFT HOOF IS GOING ON HERE?!” Santa bellowed. “Blitzen, what’s this I hear about you trying to write your own grep?!”
Blitzen froze, mid-boast about his hand-rolled, regex-powered masterpiece. “Uh, well, I thought—”
“You thought? You thought I needed a worse grep when the sleigh’s landing system is malfunctioning?!” Santa’s eyes blazed like LEDs on overclock. “Do you know where we landed yesterday?! Florida. FLORIDA, BLITZEN! You ever tried explaining a snow-laden sleigh to a guy in flip-flops?!”
Santa turned to the rest of the elves. “Everyone, listen up. Blitzen... you’re FIRED!”
The room gasped. Even the code compiler on the corner workstation seemed to pause in shock. Blitzen’s antlers drooped.
“Well, not fired,” Santa clarified, stroking his beard. “But you’re off tech lead. Effective immediately, you’re on…” he smirked, “Candy Cane API maintenance. Enjoy your new repo.”
The elves stifled giggles as Blitzen sulked away. Santa clapped his hands, bringing their attention back to the matter at hand.
“Now, here’s the real problem, folks. The sleigh’s landing system needs snow data, but look at what I got instead.” He waved a crinkled printout. “Snow weights! In kilograms and pounds! I don’t know what any of this means! What I need is actionable snow data—converted into snowballs.”
The elves exchanged worried glances.
“I want you to implement the From<T>
trait to convert these.” Santa jabbed at the paper. “We’ve got SnowKg(pub f32)
and SnowLb(pub f32)
, but I need them in a usable format: Snowball(pub i64)
! And make it snappy! Christmas Eve doesn’t debug itself!”
The room buzzed with renewed energy. The elves, though still peeved at Blitzen, couldn’t help but feel the spark of a good challenge. Snowball-ready data? Time to roll up their sleeves—and their structs.
Santa grinned as he marched out. “And if anyone so much as mentions rewriting ls
in Rust, you’re on tinsel-wrapping duty.”
From<T>
trait for the SnowKg
and SnowLb
types to convert them into Snowball
type.Snowball
type should contain the number of snowballs that can be made from the given weight.SNOWBALL_WEIGHT_KG
and SNOWBALL_WEIGHT_LB
constants to calculate the number of snowballs.If you’re stuck or need a starting point, here are some hints to help you along the way!
Use the SNOWBALL_WEIGHT_KG
and SNOWBALL_WEIGHT_LB
constants to find the number of snowballs from a weight.
Implement the From<T>
trait for each type. e.g. impl From<WeightInKg> for Snowball
.
Inside the impl From<T> for Snowball
block, calculate the number of snowballs from the input type. e.g.
fn from(weight: SnowKg) -> Self {
let value = "calculate the number of snowballs from weight";
SnowBall(value)
}
Use round()
to round the result to the nearest whole number. e.g. value.round()
.
Convert the result to an integer using as i64
.
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(kg: SnowKg) -> Self { Self((kg.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(lb: SnowLb) -> Self { Self((lb.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(kg: SnowKg) -> Self { Snowball((kg.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(lb: SnowLb) -> Self { Snowball((lb.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(SnowKg(kg): SnowKg) -> Self { Snowball((kg / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowLb to Snowball fn from(SnowLb(lb): SnowLb) -> Self { Snowball((lb / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight : SnowKg) -> Self { let n : f64 = weight.0 / SNOWBALL_WEIGHT_KG; Snowball(n.round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight : SnowLb) -> Self { let n : f64 = weight.0 / SNOWBALL_WEIGHT_LB; Snowball(n.round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;impl From<SnowKg> for Snowball { fn from(kg: SnowKg) -> Self { let n = (kg.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball(n) }}impl From<SnowLb> for Snowball { fn from(lb: SnowLb) -> Self { let n = (lb.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball(n) }}pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(value: SnowKg) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snowkg: SnowKg) -> Self { return Snowball::new((snowkg.0 / SNOWBALL_WEIGHT_KG).round() as i64); }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(snowlb: SnowLb) -> Self { return Snowball::new((snowlb.0 / SNOWBALL_WEIGHT_LB).round() as i64); }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snow:SnowKg)->Self{ let nb = (snow.0 as f64 / SNOWBALL_WEIGHT_KG).round() as i64; Self::new(nb) }}impl From<SnowLb> for Snowball { // 2. Implement the same for SnowLb fn from(snow:SnowLb)->Self{ let nb = (snow.0 as f64 / SNOWBALL_WEIGHT_LB).round() as i64; Self::new(nb) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(val: SnowKg) -> Self { Snowball((0.5 + val.0 / SNOWBALL_WEIGHT_KG) as i64) }}impl From<SnowLb> for Snowball { fn from(val: SnowLb) -> Self { Snowball((0.5 + val.0 / SNOWBALL_WEIGHT_LB) as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { Self::new((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { Self::new((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}#[derive(Debug)]pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { Self::new((weight.0/SNOWBALL_WEIGHT_KG).round() as i64) //because this is implemented for Snowball, you can just use Self. }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { Self::new((weight.0/SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}#[derive(Debug)]pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { let num_of_balls = weight.0 / SNOWBALL_WEIGHT_KG; let num_of_balls_rounded = num_of_balls.round() as i64; Snowball::new(num_of_balls_rounded) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let num_of_balls = weight.0 / SNOWBALL_WEIGHT_LB; let num_of_balls_rounded = num_of_balls.round() as i64; Snowball::new(num_of_balls_rounded) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(item: SnowKg) -> Self { Snowball::new((item.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(item: SnowLb) -> Self { Snowball::new((item.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { Self::new((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { Self::new((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Self { Snowball::new((value.0 / SNOWBALL_WEIGHT_KG + 0.5) as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowLb) -> Self { Snowball::new((value.0 / SNOWBALL_WEIGHT_LB + 0.5) as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg)->Self{ Self((value.0/SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball{ fn from(value:SnowLb) ->Self{ Self((value.0/SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(value: SnowKg) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { Snowball::new((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { Snowball::new((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;#[derive(Debug)]pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball(value) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball(value) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let val = weight.0 / SNOWBALL_WEIGHT_KG; Snowball(val.round() as i64) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let val = weight.0 / SNOWBALL_WEIGHT_LB; Snowball(val.round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight : SnowKg) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball::new(value) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight : SnowLb) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball::new(value) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Snowball { Snowball((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowLb) -> Snowball { Snowball((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Self { Self((value.0 as f64 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Self((value.0 as f64 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(value: SnowKg) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) } // 1. Implement the conversion from SnowKg to Snowball}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) } // 1. Implement the conversion from SnowKg to Snowball}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball::new(value) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball::new(value) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(qt: SnowKg) -> Self { Snowball::new((qt.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(qt: SnowLb) -> Self { Snowball::new((qt.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Snowball { let SnowKg(weight) = value; Snowball((weight/SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Snowball { let SnowLb(weight) = value; Snowball((weight/SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snowlb: SnowLb) -> Self { let SnowLb(weight) = snowlb; let value = (weight/SNOWBALL_WEIGHT_LB).round() as i64; Snowball(value) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snowkg: SnowKg) -> Self { let SnowKg(weight) = snowkg; let value = (weight/SNOWBALL_WEIGHT_KG).round() as i64; Snowball(value) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Snowball { Snowball::new((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowLb) -> Snowball { Snowball::new((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snow_kg: SnowKg) -> Snowball { Snowball::new( (snow_kg.0 / SNOWBALL_WEIGHT_KG).round() as i64 ) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowLb to Snowball fn from(snow_lb: SnowLb) -> Snowball { Snowball::new( (snow_lb.0 / SNOWBALL_WEIGHT_LB).round() as i64 ) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(qt:SnowKg)->Self{ Snowball::new((qt.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(qt:SnowLb)->Self{ Snowball::new((qt.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let count_f64 = weight.0 / SNOWBALL_WEIGHT_KG; Self::new(count_f64.round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let count_f64 = weight.0 / SNOWBALL_WEIGHT_LB; Self::new(count_f64.round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(value: SnowKg) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Snowball((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(value: SnowKg) -> Self { Self(f64::round(value.0 / SNOWBALL_WEIGHT_KG) as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { Self(f64::round(value.0 / SNOWBALL_WEIGHT_LB) as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(ball_kg: SnowKg) -> Self { let count = (ball_kg.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball::new(count) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(ball_lb: SnowLb) -> Self { let count = (ball_lb.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball::new(count) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Self { let snowballs = value.0 / SNOWBALL_WEIGHT_KG; Snowball::new(snowballs.round() as i64) }}impl From<SnowLb> for Snowball { fn from(value: SnowLb) -> Self { let snowballs = value.0 / SNOWBALL_WEIGHT_LB; Snowball::new(snowballs.round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(snow_kg: SnowKg) -> Snowball { let num: i64 = ( snow_kg.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball::new(num) }}impl From<SnowLb> for Snowball { fn from(snow_lb: SnowLb) -> Snowball { let num: i64 = (snow_lb.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball::new(num) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snow_kg: SnowKg) -> Self { let snowballs = (snow_kg.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball(snowballs) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(snow_lb: SnowLb) -> Self { let snowballs = (snow_lb.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball(snowballs) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let weight = weight.0; let value = weight / SNOWBALL_WEIGHT_KG; Self::new(value.round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowLb) -> Self { let weight = weight.0; let value = weight / SNOWBALL_WEIGHT_LB; Self::new(value.round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { Self((weight.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { Self((weight.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(other: SnowKg) -> Self { Self((other.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(other: SnowLb) -> Self { Self((other.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(weight: SnowKg) -> Snowball { let balls = (weight.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball::new(balls) }}impl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Snowball { let balls = (weight.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball::new(balls) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowKg) -> Self { Self((value.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(value: SnowLb) -> Self { Self((value.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let value = weight.0 / SNOWBALL_WEIGHT_KG; Snowball(value.round() as i64) }}// 2. Implement the same for SnowLb impl From<SnowKg> for Snowball {impl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowLb) -> Self { let value = weight.0 / SNOWBALL_WEIGHT_LB; Snowball(value.round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_KG).round() as i64; Snowball(value) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(weight: SnowLb) -> Self { let value = (weight.0 / SNOWBALL_WEIGHT_LB).round() as i64; Snowball(value) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(snow_kg: SnowKg) -> Self { Snowball((snow_kg.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { fn from(snow_lb: SnowLb) -> Self { Snowball((snow_lb.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(kg: SnowKg) -> Self { Self((kg.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(lb: SnowLb) -> Self { Self((lb.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { fn from(kg: SnowKg) -> Self { Self::new((kg.0 / SNOWBALL_WEIGHT_KG).round() as i64) }}impl From<SnowLb> for Snowball { fn from(lb: SnowLb) -> Self { Self::new((lb.0 / SNOWBALL_WEIGHT_LB).round() as i64) }}// 2. Implement the same for SnowLb
const SNOWBALL_WEIGHT_KG: f64 = 0.2;const SNOWBALL_WEIGHT_LB: f64 = 0.441;pub struct SnowKg(pub f64);impl SnowKg { pub fn new(kg: f64) -> Self { SnowKg(kg) }}pub struct SnowLb(pub f64);impl SnowLb { pub fn new(lb: f64) -> Self { SnowLb(lb) }}pub struct Snowball(pub i64);impl Snowball { pub fn new(snowballs: i64) -> Self { Snowball(snowballs) }}impl From<SnowKg> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowKg) -> Self { let value = weight.0 / SNOWBALL_WEIGHT_KG ; Snowball(value.round() as i64) }}// 2. Implement the same for SnowLbimpl From<SnowLb> for Snowball { // 1. Implement the conversion from SnowKg to Snowball fn from(weight: SnowLb) -> Self { let value = weight.0 / SNOWBALL_WEIGHT_LB; Snowball(value.round() as i64) }}