[][src]Trait polytype::Name

pub trait Name: Clone + Eq {
    fn arrow() -> Self;

    fn show(&self) -> String { ... }
fn parse(_s: &str) -> Result<Self, ()> { ... }
fn is_arrow(&self) -> bool { ... } }

Types require a Name for comparison.

We mandate that arrow be implemented for any such names, and we provide an implementation for &'static str.

Examples

Using static strings:

let t = Type::Constructed("int", vec![])

A custom implementation:

#[derive(Clone, PartialEq, Eq)]
struct N(u8);

impl Name for N {
    fn arrow() -> Self {
        N(0)
    }
}

let t: Type<N> = Type::Constructed(N(1), vec![])

Required methods

fn arrow() -> Self

A specific name representing an arrow must be declared.

Loading content...

Provided methods

fn show(&self) -> String

A way of displaying the name.

fn parse(_s: &str) -> Result<Self, ()>

To go from a particular name's string representation to a Name. This should round-trip with show.

fn is_arrow(&self) -> bool

Loading content...

Implementations on Foreign Types

impl Name for &'static str[src]

fn arrow() -> &'static str[src]

The rightwards arrow in unicode: .

fn parse(s: &str) -> Result<&'static str, ()>[src]

LEAKY because it gives the string a static lifetime.

fn is_arrow(&self) -> bool[src]

The rightwards arrow in unicode: .

Loading content...

Implementors

Loading content...