Trait Label

Source
pub trait Label {
    type Label: Display + Clone;

    // Required method
    fn label(&self) -> Self::Label;
}
Expand description

Label for a node. The label type must be very cheap to clone and move around. for strings, Arc or Rc is preferred when implementing this type.

use meshed::prelude::*;
use std::rc::Rc;

#[derive(Clone)]
struct Identifier(Rc<str>);

impl std::fmt::Display for Identifier {
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        todo!()
  }
}

struct Data {
    id: Identifier
}

impl Label for Data {
    type Label = Identifier;
    fn label(&self) -> Self::Label {
       self.id.clone()
    }
}

Required Associated Types§

Required Methods§

Source

fn label(&self) -> Self::Label

Implementations on Foreign Types§

Source§

impl<'a> Label for Chunk<'a>

Source§

type Label = ChunkId

Source§

fn label(&self) -> <Chunk<'a> as Label>::Label

Source§

impl<'a> Label for Module<'a>

Implementors§