Module giftbox::gifttag[][src]

Expand description

This module defines the GiftTag. It is meant to be used by the crate::giftwrap::GiftWrap module but can be used anywhere in Rust. The GiftTag can be imagined as a tag that is tied to a wrapped gift box. It contains the following information in Strings:

  • Recipient
  • Sender
  • Message

Examples

The GiftTag can be used on it’s own in the following way:

use giftbox::gifttag::GiftTag;
let tag = GiftTag::write(
     "Bob".to_string(),
     "Sally".to_string(),
     "Happy Cake Day!".to_string()
);

The GiftTag can be used with crate::giftwrap::GiftWrap and in the following way:

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);

Structs

The GiftTag struct represents a gift tag that could be included with a gift’s wrapping. It is used by the GiftWrap struct to include a recipient, a sender, and a message. Though it is utilized by GiftWrap, this struct can be used anywhere in Rust.