xreflect 0.1.0

Basic macros for dynamic reflection of structs/enums
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 17.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.71 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • HydrogenMacro/xreflect
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • HydrogenMacro

XReflect

A reflection library

Quickstart

use xreflect::Reflect;
// just derive Reflect
#[derive(Reflect)]
pub struct Enemy {
	pub health: u8,
}
#[derive(Reflect)]
pub enum GameState {
	Playing,
	Won { score: i32, remaining_health: u8 },
	Lost(Enemy),
}

fn main() {
	// You can now access and modify fields dynamically
	let mut enemy = Enemy { health: 2 };

	let enemy_health = enemy.get_field::<u8>("health");
	assert_eq!(enemy_health, &2);
	enemy.set_field::<u8>("health", 7);
	assert_eq!(enemy_health, &7);
}