Skip to main content

Platin

Trait Platin 

Source
pub trait Platin {
    // Required method
    fn to_platin(&self) -> String;
}

Required Methods§

Source

fn to_platin(&self) -> String

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Platin for str

Source§

fn to_platin(&self) -> String

to_platin is the main method for converting &strs into Pig-Latinified Strings.

§Examples
use igpay::Platin;

let foo = "Hello, amazing world!";
let bar = String::from("Hello, amazing world!");

assert_eq!("ellohay amazinghay orldway", foo.to_platin());

// Of course, to_platin works with a &String too as it coerces to &str.
assert_eq!("ellohay amazinghay orldway", &bar.to_platin());
§Dealing with non-English strings

to_platin is designed only for use with the English language, or languages that have the same vowel configuration as is defined in VOWELS.

This doesn’t mean to_platin won’t try!

There is no functionality for to_platin to panic or return an error etc. if it encounters a language that it is not designed for.

It will follow the same rules as usual:

use igpay::Platin;

assert_eq!("あ".to_platin(), "あay");
§Panics

to_platin will only panic if the value at pos 0 in the chars iterator returns None. This probably will never happen, though, and so should be reported as an issue on the GitHub page.

Implementors§