Crate rvstruct

source ·
Expand description

Value Structs derive macros for Rust to support the newtype pattern

A very simple derive macros to support strong type system and the new type pattern (

For example:

use rvstruct::ValueStruct;

struct UserId(String);

let uid : UserId = "my-uid".into();

ValueStruct generates for you:

  • std::convert::From<> instances automatically to help you to create your structs.
  • ValueStruct::value() function to access your field directly without using .0.

There are different behaviour for different field types:

  • for std::string::String it generates additional instance for From<&str>


Derive Macros