Name

Trait Name 

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

    // Provided methods
    fn show(&self) -> String { ... }
    fn parse(_s: &str) -> Result<Self, ParseError> { ... }
    fn is_arrow(&self) -> bool { ... }
}
Expand description

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§

Source

fn arrow() -> Self

A specific name representing an arrow must be declared.

Provided Methods§

Source

fn show(&self) -> String

A way of displaying the name.

Source

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

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

Source

fn is_arrow(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Name for &'static str

Source§

fn arrow() -> &'static str

The rightwards arrow in unicode: .

Source§

fn parse(s: &str) -> Result<&'static str, ParseError>

LEAKY because it gives the string a static lifetime.

Source§

fn is_arrow(&self) -> bool

The rightwards arrow in unicode: .

Source§

fn show(&self) -> String

Implementors§