Module giftbox::giftwrap [−][src]
Expand description
This module defines the GiftWrap
struct. This can be used by crate::giftbox::GiftBox
to
wrap itself. It is meant to represent wrapping paper used to wrap a gift box. The struct has
four fields:
- contents - which is a generic data type that can hold any Rust definable type.
- pattern - the
crate::patterns::Patterns
enum which represents the type of wrapping paper. - has_box - a boolean which represents whether or not the
GiftWrap
has a bow. - tag - an
Option<GiftTag>
, where theGiftTag
is a struct representing a gift tag theGiftWrap
that contains the recipient, sender, and a message.
Examples
Wrap and unwrap a crate::giftbox::GiftBox
with a tag:
use giftbox::giftbox::GiftBox;
use giftbox::gifttag::GiftTag;
use giftbox::patterns::Patterns;
let filled_box = GiftBox::fill(Some(["Toys", "Candy", "Money"]));
let tag = GiftTag::write(
"Bob".to_string(),
"Sally".to_string(),
"Happy Cake Day!".to_string()
);
let wrapped_box = filled_box.wrap(
Patterns::Polkadots,
true,
Some(tag)
);
let unwrapped_box = wrapped_box.unwrap();
assert_eq!(unwrapped_box, filled_box);
todo!() Turn GiftWrap into a trait.
Structs
A GiftWrap
type for Rust which represents gift wrap that can be wrapped around any other
type that can be represented as a Rust type.