“BLITZEN! GET IN HERE!” Santa’s furious voice echoed through the workshop.
Blitzen stepped inside cautiously. It had been only a few hours since Santa forgave him for the "great grep fiasco"—when Blitzen had decided to re-write grep
from scratch.
“I thought we were good now!” Blitzen said.
“Well, WE’RE NOT!” Santa shouted, spinning his monitor around. “LOOK AT THIS!”
Blitzen squinted at Santa’s inbox, now overflowing with spam emails:
“What happened?” Blitzen asked.
“I LEAKED MY EMAIL ON TWITCH!” Santa bellowed. “I was streaming my lecture on why Rust traits are better than cookies when I accidentally typed my real address live on stream!”
The chat, of course, had gone wild:
Chat: “LMAO! Bro just doxxed himself live.” “The spam bots are already in his inbox.”
“And it's all because of YOU!” Santa continued.
“ME? How is this my fault?” Blitzen asked, bewildered.
“If you hadn’t wasted the morning re-writing grep
, you’d have caught this issue before it happened!” Santa snapped, slamming his candy cane onto the desk. “Now you’re going to fix it. Write me an API that anonymizes email addresses—Christmas style. Replace the local part with festive emojis, and make sure it doesn’t crash on invalid emails. Do it NOW!”
Blitzen sighed and opened Vim. “Okay, okay… I’m on it.”
Blitzen as always is in trouble—again.
Here's what you gotta do to help him out:
[email protected]
should be anonymized to 🎅🎄🎁🎄🎅@north.pole
.santa
should be anonymized to 🎅🎄🎁🎄🎅
.Here's how Santa likes to use this API:
Figure out a way to make this work, otherwise Blitzen will not get his cookies this Christmas!
If you're stuck or need a starting point, here are some hints to help you along the way!
You can extend the String
type by implementing a trait for it.
Define a trait named Anonymize
with a method named anonymize_email
that returns a String
.
Implement the trait for the String
type.