eg

Crates.ioeg
lib.rseg
version0.1.2
sourcesrc
created_at2022-09-16 20:19:03.40027
updated_at2022-09-17 01:43:44.135669
descriptionEasy dummy data.
homepage
repositoryhttps://github.com/wabisabia/eg
max_upload_size
id667676
size14,910
Christian Dunn (wabisabia)

documentation

README

Eg: Default for dummy data.

github crates.io license

Why Eg?

Use Eg to provide example values:

use eg::Eg;

#[derive(Debug, PartialEq, Eg)]
struct Wizard {
	#[eg = "Harry Potter"]
	name: String,
	#[eg = "11"]
	age: usize,
	#[eg = "totally_random_spell"]
	fav_spell: Spell,
}

#[derive(Debug, PartialEq)]
enum Spell {
	Expelliarmus,
	WinguardiumLeviosa,
}

fn totally_random_spell() -> Spell {
	Spell::Expelliarmus
}

assert_eq!(
	Wizard {
		name: "Harry Potter".to_string(),
		age: 11,
		fav_spell: Spell::Expelliarmus
	},
	Wizard::eg()
);

When Default doesn't make sense, isn't available, or isn't expressive enough:

#[test]
fn my_database_test() {
	// database stuff ...
	db.insert(Wizard::eg());
	// more database stuff ...
}

Why not a global const?

In const-compatible contexts, this is probably an acceptable approach! For everything else, there's Eg 😉

Contribution

This crate is still learning to walk; feedback, issues and PRs are all welcome! (◕‿◕)

Commit count: 12

cargo fmt