Crate uuid_to_pokemon

source ·
Expand description

This simple crate allows you to translate a UUID to a pokémon name. The purpose is to provide simple names to address objects, so you can easily talk with people about the objects.

The function is not injective. This means several UUIDs will give the same name. We don’t consider it an issue since context (like owner of object) will help dedup the search.

Examples

extern crate uuid;
extern crate uuid_to_pokemon;

use uuid::Uuid;
use uuid_to_pokemon::uuid_to_pokemon;
use std::fmt::Write; // needed for write!

fn main() {
    let my_uuid = Uuid::nil();
    let result = uuid_to_pokemon(my_uuid);

    // format it:
    let s = format!("`{}` as pokemon: `{}`", my_uuid, result);
    assert_eq!(s, "`00000000-0000-0000-0000-000000000000` as pokemon: `Busy bulbasaur`");

    // write it into an existing String:
    let mut s = "foo bar - ".to_string();
    write!(s, "pokemon: `{}`", result).unwrap();
    assert_eq!(s, "foo bar - pokemon: `Busy bulbasaur`");

    // if you need a simple String, use the to_string function:
    let s = result.to_string();
    assert_eq!(s, "Busy bulbasaur");
}

Structs

Represents the result of uuid_to_pokemon.

Functions

Converts an Uuid into a PokemonUuid.