boring-derive

Crates.ioboring-derive
lib.rsboring-derive
version0.1.1
sourcesrc
created_at2024-07-02 21:53:47.091303
updated_at2024-07-04 04:45:07.69957
descriptionDerive macros for some common patterns
homepage
repositoryhttps://github.com/BenPski/boring-derive
max_upload_size
id1289969
size36,359
Ben (BenPski)

documentation

README

boring-derive

Derive macros for simple implementations of traits.

For example From usually has very trivial implementations.

enum Thing {
  Item1(String),
  Item2(usize),
  Item3(f32),
}

impl From<String> for Thing {
  fn from(value: String) -> Self {
    Thing::Item1(value)
  }
}

impl From<usize> for Thing {
  fn from(value: usize) -> Self {
    Thing::Item2(value)
  }
}

impl From<f32> for Thing {
  fn from(value: f32) -> Self {
    Thing::Item3(value)
  }
}

So instead just:

#[derive(From)]
enum Thing {
  Item1(String),
  Item2(usize),
  Item3(f32),
}
Commit count: 22

cargo fmt